Posted by tony on September 27, 2017

How to Install phpMyAdmin on CentOS 7

phpMyAdmin is a very popular tool for administration of relational databases like MySQL and MariaDB. However, it doesn't come installed by default. In this article, we'll see how to install phpMyAdmin on CentOS 7.

Why choose phpMyAdmin over the command line?

All that phpMyAdmin does can be done over the MySQL command line as well. For instance, if you have a database dump in the form of sql statements, you can simply do this to import all the data:

$ mysql < input_file.sql

Similarly, there are commands for importing from and exporting to a CSV file.

But that's the point; in order to use the command line effectively, you need to be well versed in the quirks of the command line, as well as master a few commands and their options related to MySQL administration. This might be fine for system administrators, but for the average developer this sometimes feels like asking too much.

This is where phpMyAdmin helps. It offers a neat and useful graphical interface to do pretty much everything you can imagine with the database. Exporting databases, importing files, modifying tables – all this is made super-easy by phpMyAdmin.

Requirements for Installing phpMyAdmin on CentOS 7

This article assumes that you have a CentOS server set up, and that you are logged in as the root user. More specifically, make sure you have the following set up and running:

Apache 2.4
PHP version 5.4 or above (it's best to use PHP 7 these days)
Database: MySQL 5.4, or MariaDB 5.5

MariaDB is an open source alternative to MySQL, which was acquired by Oracle recently. So, if you're planning to use MariaDB, bear in mind that with time, the incompatibilities between the versions will grow and you'll need to stick to one of them. In other words, MariaDB won't be a "drop-in replacement for MySQL" for too long.

Installing phpMyAdmin on CentOS 7

phpMyAdmin is neither installed by default in CentOS 7, nor is it available as a package. If you do # yum install phpMyAdmin at this point, you'll get an error.

For this to work, you need to add another repository to your installation. The phpMyAdmin package is available in the EPEL repository (in case you're wondering, EPEL stands for Extra Packages for Enterprise Linux). You can add this repository by issuing the following command:

# yum install epel-release

Allow it some time to search for the repository and add it to your system.

Congratulations! You now have phpMyAdmin available for installed. To do this, simply run the following command:

# yum install phpmyadmin

Once the installation is over, you need to make sure the Apache server plays nicely with the phpMyAdmin installation. To ensure this, you need to edit a configutation file. Here's how to do it.

Using your favorite text editor (we use vi in this example, but ed, nano, all will work just fine), open the file /etc/httpd/conf.d/phpMyAdmin.conf as follows:

# vi /etc/httpd/conf.d/phpMyAdmin.conf

Now find the block which says "Apache 2.4" and change it to look like this:

# Apache 2.4
# Require ip
# Require ip ::1
Require all granted

Note that the lines starting with '#' are nothing but comments that are ignored by the Apache server, so in effect it's only the last line we're interested in.

Once this done, save the file and close it.

Now you need to restart the Apache server for these settings to take effect:

# systemctl restart httpd.service

And that's it! You now have phpMyAdmin installed and running on your machine.

Accessing phpMyAdmin on CentOS 7

By convention, the phpMyAdmin installation is accessible on '/phpmyadmin' on your server IP or domain name. This means that if, for example, your server domain name is, then phpMyAdmin will be available on

Once done, the phpMyAdmin home screen will open, and you can log in using the credentials you provided during the installation.

Leave a Reply

Your email address will not be published. Required fields are marked *