In this tutorial we will cover the steps needed to install and secure phpMyAdmin on your CentOS, Debian or Ubuntu platform.

Requirements

phpMyAdmin is a free open-source application written in PHP. It is arguably the most popular MySQL database management tool.

Install phpMyAdmin

CentOS:

We can easily install phpMyAdmin and all of its dependencies using the yum package manager:

Debian/Ubuntu:

We can install phpMyAdmin along with all of its dependencies using the apt package manager:

During the installation you will be prompted to select the web server type with which the phpMyAdmin should be configured – Apache or Lighttpd. Select Apache. After that you will be prompted to install a database required by the phpMyAdmin or skip the process for manual configuration. If you choose to configure a database for phpMyAdmin you need to select "Yes". Leave the fields empty and finish the setup.

Configure and secure phpMyAdmin

CentOS:

We will edit the phpMyAdmin virtual host file generated during the installation:

Change the 127.0.0.1 IP address with your current one. You can use the following website to obtain your current IP address: http://www.whatismyip.com/

This way phpMyAdmin will be accessible only from your IP address. You can enter multiple IP addresses by separating them with spaces, for example:

Next, we need to edit /usr/share/phpmyadmin/config.inc.php and set a "blowfish_secret" in it:

Fill in a random secret word, for example:

When ready save the file and restart the Apache service:

Debian/Ubuntu:

Open the configuration file:

and add the following lines within the <Directory /usr/share/phpmyadmin> directive:

where X.X.X.X is your IP address.

You can enter multiple IP addresses by separating them with spaces, for example:

When ready save the file and restart the Apache service:

Test the functionality of the phpMyAdmin tool

Once the configuration is completed you can test the phpMyAdmin tool using your browser:

where X.X.X.X is your server's IP address, i.e. http://1.2.3.4/phpmyadmin

You will be prompted to fill in MySQL login credentials. You can use the root user and its password, if you have set one.

An easy way to find your server's IP address is to execute the following command: