InfoWorld how-to's

How to get started with MySQL

An easy step-by-step guide to setting up a MySQL database server, along with phpMyAdmin, on Fedora, CentOS, or Ubuntu

InfoWorld how-to's

Show More
1 2 3 4 Page 3
Page 3 of 4

Managing MySQL with phpMyAdmin
Once the application is installed and tested, you will want to keep tabs on the database and perhaps move into more advanced database management. For many implementations, the use of Web-based tools can make managing the database much simpler and easier for those who are not well versed in MySQL administration.

One of these tools is phpMyAdmin, which is a PHP-based MySQL administration tool. It provides a simple and easy Web GUI for performing nearly all MySQL administrative tasks. Installing it will make everyone's life easier.

To do this on Fedora and CentOS, we run this command as root:

# yum install phpmyadmin

On Ubuntu, we run:

$ sudo apt-get install phpmyadmin

Ubuntu will prompt for the Web server in use so that it can do automatic configuration. In most cases you'll be using Apache, so select that unless you're working with lighttpd or another Web server. In addition, Ubuntu will prompt you to choose manual or automatic configuration of phpMyAdmin. Unless you're comfortable doing this manually, you can safely choose the automatic configuration, which will ask for the MySQL root password. Following this, Ubuntu will configure everything and restart the servers. However, depending on how the server was initially built, you may also need to install the Apache PHP module like this:

$ sudo apt-get install libapache2-mod-php5

On Fedora and CentOS we need to make a few minor changes in order to access phpMyAdmin from remote systems. We'll use nano to edit the phpMyAdmin configuration file:

# nano /etc/httpd/conf.d/phpmyadmin.conf

When the file opens, add a line below "Allow from 127.0.0.1" and input the IP addresses or ranges that you want to allow access to. This may be "Allow from 192.168.1," which will allow everything in the 192.168.1.0/24 subnet to connect or a specific IP address. You can add multiple lines to allow multiple IPs or subnets.

Once you've added those lines, save the file with Ctrl-O and exit with Ctrl-X. Now restart Apache:

# service httpd restart

On Fedora and CentOS, we also need to insert a Blowfish secret into the phpMyAdmin configuration. We can do that with nano too.

# nano /usr/share/phpMyAdmin/config.inc.php

(Note: You may find only a config.sample.inc.php file in the phpMyAdmin directory. If so, make a copy named config.inc.php.)

Locate the line reading:

$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

Enter a secret between the quotes, like this:

$cfg['blowfish_secret'] = 'SDJkjshdkfjhsdf9**&^%^&%'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

The secret can be anything, preferably very random. You will not need to use this secret anywhere else; it's an internal requirement. Save the file with Ctrl-O and exit with Ctrl-X.

Now we can log in to phpMyAdmin by pointing a Web browser at the server with this URL.

http://<server IP address>/phpmyadmin

46TC-mysql-howto-phpMyAdmin.gif
1 2 3 4 Page 3
Page 3 of 4