Author Photo

Ahmer's SysAdmin Recipes is a blog for Linux System Administrators. This blog provides recipes for Installation & Configuration of Linux, Ubuntu, Oracle Database, MySQL, Apache, Nginx, Oracle Cloud Control, FreeIPA, Kerberos & OpenLDAP, Subversion, PXE, DevOps, etc. over Red Hat Enterprise Linux (RHEL), CentOS, Ubuntu and Windows.

Please give me your feedback and help me improve this blog. Please let me know If you want me to write on a specific topic.

Friday, 26 February 2016

Install phpMyAdmin on CentOS 7 LAMP Server

Install phpMyAdmin on CentOS 7 LAMP ServerphpMyAdmin is a free and open source tool written in PHP. phpMyAdmin is intended to handle the administration of MySQL or MariaDB through a Web UI (User Interface). Database Administrators uses phpMyAdmin to perform various tasks such as creating, modifying or deleting databases, tables, fields or rows; executing SQL statements; managing users and permissions; or monitoring database instances.

In this article, we will install phpMyAdmin on a CentOS 7 LAMP server.


System Specification:

In this article, we use the same CentOS 7 LAMP server, that we have configured in our previous post Install Linux, Apache, MySQL & PHP (LAMP) Stack).

IP Address
Operating System CentOS 7
Apache HTTP Server 2.4.6
MySQL Server 5.7
PHP 5.4


Install phpMyAdmin on CentOS 7 LAMP Server:

Browse to to download a compatible version of phpMyAdmin according to your LAMP stack versions.

We have downloaded phpMyAdmin according to our LAMP Stack versions. phpMyAdmin is available in various zip format and languages, you should select one according to your requirement.

[root@lampserver ~]# cd /soft [root@lampserver soft]# wget

Extract the zip file and move the extracted directory to the Apache HTTP Server’s document root.

[root@lampserver soft]# tar -xvf phpMyAdmin- [root@lampserver soft]# mv phpMyAdmin- /var/www/html/phpmyadmin

Reapply the SELinux security context for the phpmyadmin directory.

[root@lampserver soft]# restorecon -Rv /var/www/html

phpMyAdmin requires following php modules to be installed. Therefore, install it as folllows:

[root@lampserver soft]# yum install -y php-mbstring [root@lampserver soft]# systemctl restart httpd.service

Connect to MySQL database server.

[root@lampserver soft]# mysql -u root –p

Create phpMyAdmin repository using create_tables.sql script, provided in phpMyAdmin zip file.

mysql> source /var/www/html/phpmyadmin/sql/create_tables.sql mysql> GRANT SELECT, INSERT, UPDATE, DELETE ON phpmyadmin.* TO 'pma'@'localhost' IDENTIFIED BY 'Pma$1234'; mysql> quit

Although, phpMyAdmin can be run with zero configuration, but it is a good idea to configure some security related parameters. To create a config file for phpMyAdmin using setup script, execute following commands:

[root@lampserver soft]# mkdir /var/www/html/phpmyadmin/config [root@lampserver soft]# chmod o+rw /var/www/html/phpmyadmin/config [root@lampserver soft]# cp /var/www/html/phpmyadmin/ /var/www/html/phpmyadmin/config/ [root@lampserver soft]# chown -R apache:apache /var/www/html/

Create SELinux policy for the config directory to allow web server to write on it.

[root@lampserver soft]# semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/phpmyadmin/config(/.*)?" [root@lampserver soft]# restorecon -Rv /var/www/html [root@lampserver soft]# systemctl restart httpd.service

Browse to URL to create a config file with custom settings and amend the settings according to your requirement.

You can see some examples of settings in the below screenshots.


Once done, Save the settings, it will give you the advise to move the file to phpMyAdmin web root and remove the config file.

[root@lampserver soft]# mv /var/www/html/phpmyadmin/config/ /var/www/html/phpmyadmin/ [root@lampserver soft]# rm -rf /var/www/html/phpmyadmin/config/

Browse to URL

phpMyAdmin-login-01 phpMyAdmin-dashboard-01

phpMyAdmin has been successfully installed on CentOS 7 LAMP server, we can now manage our MySQL databases from phpMyAdmin Web UI.

Install phpMyAdmin on CentOS 7 LAMP Server



  1. In some cases, you have to explicitly define the Storage Mappings for pmadb tables in file like

    $cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
    $cfg['Servers'][$i]['relation'] = 'pma__relation';
    $cfg['Servers'][$i]['table_info'] = 'pma__table_info';
    $cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
    $cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
    $cfg['Servers'][$i]['column_info'] = 'pma__column_info';
    $cfg['Servers'][$i]['history'] = 'pma__history';
    $cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';
    $cfg['Servers'][$i]['tracking'] = 'pma__tracking';
    $cfg['Servers'][$i]['designer_coords'] = 'pma__designer_coords';
    $cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
    $cfg['Servers'][$i]['recent'] = 'pma__recent';

  2. Additionally change the user, password to controluser, controlpassword respectively to enable utilization of storage features for others users without having the privileges on the pmadb.

    $cfg['Servers'][$i]['controluser'] = 'pma';
    $cfg['Servers'][$i]['controlpass'] = '123';