How To Install phpMyAdmin on CentOS 7

How To Install phpMyAdmin on CentOS 7

phpMyAdmin is a free web-based tool for managing the MySQL, MariaDB and Drizzle database servers. It is a really useful tool for who are newbie or nowise in database related activities.

phpMyAdmin helps you performing almost all databases activities such as creating, deleting and querying tables, users, permissions, columns, relations, indexes, etc.

This post will help you to install the latest version of phpMyAdmin v4.4 on CentOS 7.

Prerequisites

Install MySQL / MariaDB Server

Before installing phpMyAdmin, you must have at least one database instance be it standalone server or installed as part of the LAMP stack.

Standalone Database

   1.How To Install MySQL 8.0 on CentOS 7

Install PHP and MySQL support package for PHP on your system for phpMyAdmin to connect with database

yum -y install php php-mysql

LAMP Stack

   1.How To Install LAMP Stack On CentOS 7

Enable EPEL repository

phpMyAdmin package is available in the EPEL repository. So, Install EPEL repository rpm on to your system by running the below command.

yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

Install phpMyAdmin

Installing phpMyAdmin is very simple. You can install phpMyAdmin using the yum command.

MySQL v8.0 / LAMP Stack with PHP 5.4:

yum -y install phpmyadmin

LAMP Stack with PHP 7.3:

yum install –enablerepo=remi-php73 phpmyadmin

Configure phpMyAdmin

By default, phpMyAdmin is accessible to localhost only which means you can’t access phpMyAdmin’s web interface from external machines.

We have to edit the phpMyAdmin.conf file as phpMyAdmin places the configuration files in /etc/httpd/conf.d directory as it has rules and permission for remote access.

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

Default config will look like below:

Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin

<Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8

   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       Require ip 127.0.0.1
       Require ip ::1
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 127.0.0.1
     Allow from ::1
   </IfModule>
</Directory>

<Directory /usr/share/phpMyAdmin/setup/>
   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       Require ip 127.0.0.1
       Require ip ::1
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 127.0.0.1
     Allow from ::1
   </IfModule>
</Directory>

Please remove or comment out Require ip 127.0.0.1 and Require ip ::1. Then add Require all granted to the configuration file.

After your modification the configuration will look like below:

Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin

<Directory /usr/share/phpMyAdmin/>
     AddDefaultCharset UTF-8

     <IfModule mod_authz_core.c>
        # Apache 2.4
        <RequireAny>
             Require all granted
        </RequireAny>
     </IfModule>
     <IfModule !mod_authz_core.c>
        # Apache 2.2
        Order Deny,Allow
        Deny from All
        Allow from 127.0.0.1
        Allow from ::1
     </IfModule>
</Directory> <Directory /usr/share/phpMyAdmin/setup/>
     <IfModule mod_authz_core.c>
        # Apache 2.4
        <RequireAny>
            Require all granted
        </RequireAny>
     </IfModule>
     <IfModule !mod_authz_core.c>
        # Apache 2.2
        Order Deny,Allow
        Deny from All
        Allow from 127.0.0.1
        Allow from ::1
     </IfModule>
</Directory>

Restart the web service.

systemctl restart httpd

Firewall

Configure the firewall to allow HTTP web requests from external networks.

firewall-cmd --permanent --add-service=http
firewall-cmd --reload

Important Notes

Read the important notes before accessing phpMyAdmin with root or regular database user.

MySQL 8.x

MySQL 8 uses caching_sha2_password mechanism for authentication which prevents legacy application to access databases including phpMyAdmin at this moment. In simple terms, you won’t be login to phpMyAdmin unless we disable this new password mechanism.

You can globally disable it by putting default-authentication-plugin=mysql_native_password in /etc/my.cnf (Any users created after this change will have mysql_native_password authentication mechanism) or revert to the old native authentication (mysql_native_password) for individual users by running ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '<password>'; command in MySQL terminal.

Access phpMyAdmin

Now access the phpMyAdmin web interface using the browser.

URL will be:

http://your_ip_address/phpMyAdmin

Log in as the DB root user or any database user.

phpMyAdmin Login Page

You will get the database page where you can manage all your databases.

phpMyAdmin Databases Page

Conclusion

You have successfully set up phpMyAdmin on CentOS 7 to manage your MySQL / MariaDB servers. You can visit phpMyAdmin’s official documentation to get an understanding of what you can do with phpMyAdmin.

comments powered by Disqus