phpMyAdmin handles the administration of MySQL over the Web. It can manage a whole MySQL server as well as a single database. For more information please see http://www.phpmyadmin.net/

To install phpmyadmin, run the following commands


# cd /usr/ports/databases/phpmyadmin
# make install clean

Leave everything checked other than Improved MySQL support and tab down to OK.

Before we continue rainloop will add some apache modules so we should restart apache:


# /usr/local/etc/rc.d/apache24 restart

Now you must configure your installation.


# cd /usr/local/www/phpMyAdmin
# cp config.inc.php.sample config.inc.php

Now to edit the /usr/local/etc/apache24/httpd.conf file:


# vi /usr/local/etc/apache24/httpd.conf

Scroll down where you see the first <Directory> statement:


<Directory />
AllowOverride None
Order deny,allow
Deny from all
<Directory>

And add the following:


Alias /phpmyadmin "/usr/local/www/phpMyAdmin"

</Directory "/usr/local/www/phpMyAdmin">
Options None
AllowOverride None
Require all granted
</Directory>

Exit and then restart Apache:


# apachectl restart

Now to add a user with "superuser" options for mysql, heres how to do it:


# mysql -u root -p

When you get to the mysql> prompt type:


GRANT ALL PRIVILEGES ON *.* TO mysqluser@localhost IDENTIFIED BY 'password' WITH GRANT OPTION;

This is the same user/pass combination that you created in the config.inc.php page.

Now if you go to http://yoursite.com/phpmyadmin you should get a phpmyadmin page. Use the username and password you set above to login.

If you get a forbidden page, You will want to check the Allow from line in the Directory statement above and make sure it lists the network you are coming from. If not, All you will get is a forbidden message.

You can also Add security to your setup as seen below:

Alias /phpmyadmin/ "/usr/local/www/phpMyAdmin/"

Options none
AllowOverride Limit
Order Deny,Allow

# Deny from all
Require ip 192.168.0.0/24
##Additional lines you can add as needed for more IP addresses
Allow from 127.0.0.1 192.168.0.0/24 216.7.8.20