How to install phpMyAdmin on CentOS 8

Share on Social Media

Follow our comprehensive guide to install phpMyAdmin on CentOS 8. Get clear, step-by-step instructions to configure phpMyAdmin and manage your MySQL databases with ease. #centlinux #linux #mysql

What is phpMyAdmin?

phpMyAdmin is the most widely used software for database administration of MariaDB/MySQL databases. phpMyAdmin is written in PHP and JavaScript and distributed under GNU GPL 2 license.

MariaDB/MySQL does not include a native GUI interface for database administration. Therefore, we install phpMyAdmin side by side on the MariaDB/MySQL server to provide a web user interface to sysadmins and developers.

In this lab, you will learn how to install phpMyAdmin on CentOS 8 server.

Recommended Training for You: SQL: Master SQL With PhpMyAdmin and MYSQL Engine

2686550 a0a2 3show?id=oLRJ54lcVEg&offerid=1597309.391977027109908647630551&bids=1597309

phpMyAdmin Features

Some of the features of phpMyAdmin are:

  • create, browse, edit, and drop databases, tables, views, columns, and indexes
  • create, copy, drop, rename and alter databases, tables, columns and indexes
  • execute, edit and bookmark any SQL-statement, even batch-queries
  • load text files into tables
  • create and read dumps of tables

For complete list of features, please refer to phpMyAdmin documentation.

phpMyAdmin System Requirements

phpMyAdmin 5.0.1 needs following software prerequisites.

  • Webserver – Apache, nginx, IIS
  • PHP – 7.1.3 or later
  • Database – MySQL/MariaDB 5.5 or later

phpMyAdmin Alternatives

If you’re looking for alternatives to phpMyAdmin for managing MySQL or MariaDB databases, there are several other tools and platforms available. Here are some of the best phpMyAdmin alternatives, each with its own set of features and benefits:

1. Adminer

  • Description: A lightweight and straightforward database management tool that supports MySQL, PostgreSQL, SQLite, and more.
  • Key Features:
  • Single PHP file application
  • User-friendly interface
  • Supports multiple database systems
  • Easy to install and configure
  • Website: Adminer

2. MySQL Workbench

  • Description: A comprehensive desktop application for MySQL database design, development, and administration.
  • Key Features:
  • Visual database design and modeling
  • SQL query editor
  • Performance monitoring tools
  • Database migration features
  • Website: MySQL Workbench

3. DBeaver

  • Description: A powerful, open-source database management tool that supports multiple database types, including MySQL, PostgreSQL, SQLite, and more.
  • Key Features:
  • Support for a wide range of database systems
  • Advanced SQL editor with autocomplete
  • Data export and import capabilities
  • ER diagrams and data visualization
  • Website: DBeaver

4. HeidiSQL

  • Description: A lightweight Windows application for managing MySQL, MariaDB, and PostgreSQL databases.
  • Key Features:
  • User-friendly interface
  • Session management and SQL query editor
  • Data export and import tools
  • Supports SSH tunneling for secure connections
  • Website: HeidiSQL

5. Sequel Pro

  • Description: A macOS application for managing MySQL databases, offering an intuitive and easy-to-use interface.
  • Key Features:
  • Native macOS application
  • Simple and clean user interface
  • Query editor and table management
  • Support for SSH connections
  • Website: Sequel Pro

6. SQuirreL SQL

  • Description: An open-source SQL client for Java that supports a variety of database systems.
  • Key Features:
  • Plugin-based architecture
  • Cross-platform (Java-based)
  • Database browsing and SQL editor
  • Supports multiple database connections
  • Website: SQuirreL SQL

7. TablePlus

  • Description: A modern, native database management tool for MySQL, PostgreSQL, SQLite, and other databases.
  • Key Features:
  • Clean and intuitive interface
  • Multi-tab and multi-window support
  • Advanced query editor
  • Security features and encryption support
  • Website: TablePlus

8. Valentina Studio

  • Description: A powerful database management tool with a free version that supports MySQL, PostgreSQL, and SQLite.
  • Key Features:
  • Visual database design and query building
  • Data and schema comparison tools
  • Data import and export features
  • Built-in SQL editor
  • Website: Valentina Studio

9. Beekeeper Studio

  • Description: A modern, open-source SQL editor and database manager for MySQL, PostgreSQL, SQLite, and more.
  • Key Features:
  • Cross-platform support (Windows, macOS, Linux)
  • Query builder and editor
  • Data visualization and management
  • Table management features
  • Website: Beekeeper Studio

10. MySQL Shell

  • Description: A command-line interface for MySQL that includes scripting capabilities for advanced database management.
  • Key Features:
  • Supports SQL, JavaScript, and Python scripting
  • Advanced features for database management
  • Integration with MySQL InnoDB Cluster
  • Website: MySQL Shell

Comparing phpMyAdmin Alternatives

ToolPlatformKey FeaturesPrice
AdminerWeb-basedLightweight, multiple DB supportFree
MySQL WorkbenchWindows/macOS/LinuxVisual design, SQL editor, performance toolsFree
DBeaverWindows/macOS/LinuxMulti-DB support, ER diagramsFree
HeidiSQLWindowsLightweight, SSH supportFree
Sequel PromacOSNative macOS app, query editorFree
SQuirreL SQLJava-basedMulti-DB support, plugin-basedFree
TablePlusWindows/macOS/LinuxModern UI, multi-tab supportPaid
Valentina StudioWindows/macOS/LinuxVisual design, comparison toolsFree/Paid
Beekeeper StudioWindows/macOS/LinuxModern UI, cross-platformFree
MySQL ShellWindows/macOS/LinuxAdvanced scripting, InnoDB ClusterFree
Comparing phpMyAdmin Alternatives

These alternatives offer various features that may better suit your specific needs or preferences compared to phpMyAdmin.

Feel free to explore these options to find the best tool for your database management needs!

Linux Server Specification

We are using a minimal CentOS 8 virtual machine with following specification.

  • CPU – 3.4 Ghz (2 cores)
  • Memory – 2 GB
  • Storage – 20 GB
  • Operating System – CentOS 8.0
  • Hostname – phpmyadmin-01.sysadminlabs.com
  • IP Address – 192.168.116.206 /24

Install LAMP Stack on CentOS 8

phpMyAdmin is a PHP based web application that requires PHP hypertext preprocessor and a supported web server for deployment. Therefore, we are installing LAMP Stack on CentOS 8.

Apache, MariaDB (a MySQL variant) and PHP are available in standard yum repositories, thus we can install them using a dnf command.

# dnf install -y @mariadb @httpd @php

Install php-mysqlnd package for PHP to MariaDB connectivity.

# dnf install -y php-mysqlnd

Enable and start MariaDB service.

# systemctl enable --now mariadb.service
Created symlink /etc/systemd/system/mysql.service â /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service â /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service â /usr/lib/systemd/system/mariadb.service.

Configure MariaDB instance and set root user password.

# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorization.

Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
... Success!

Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Test MariaDB database connectivity.

# mysql -u root -p123
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 16
Server version: 10.3.17-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

MariaDB [(none)]>

Create a directory to store SSL certificate and private key.

# mkdir /etc/httpd/ssl

Generate a self signed SSL certificate using openssl command. You can also generate a CSR (Certificate Signing Request) and get it signed by a Certificate Authority Server in your network.

# openssl req -x509 -nodes -days 1095 -newkey rsa:2048 -out /etc/httpd/ssl/lamp.crt -keyout /etc/httpd/ssl/lamp.key
Generating a RSA private key
...........................+++++
.............................................................+++++
writing new private key to '/etc/httpd/ssl/lamp.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:PK
State or Province Name (full name) []:Sindh
Locality Name (eg, city) [Default City]:Karachi
Organization Name (eg, company) [Default Company Ltd]:Ahmer's SysAdmin Recipes
Organizational Unit Name (eg, section) []:IT Lab
Common Name (eg, your name or your server's hostname) []:phpmyadmin-01.sysadminlabs.com
Email Address []:root@phpmyadmin-01.sysadminlabs.com

Edit Apache configuration files to add SSL certificate and private key.

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

Find and update following directives in this file.

SSLCertificateFile /etc/httpd/ssl/lamp.crt
SSLCertificateKeyFile /etc/httpd/ssl/lamp.key

Enable and start Apache service.

# systemctl enable --now httpd.service
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service â /usr/lib/systemd/system/httpd.service.

Enable and start php-fpm service.

# systemctl enable --now php-fpm.service
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service â /usr/lib/systemd/system/php-fpm.service.

Allow Apache default service port in CentOS 8 firewall.

# firewall-cmd --permanent --add-service=https
success
# firewall-cmd --reload
success

Open URL https://phpmyadmin-01.sysadminlabs.com in a web browser.

If you are using a self signed SSL certificate, then browser will display a security warning. Ignore it and continue.

Apache Server Default Webpage
Apache Server Default Webpage

Our LAMP Server has been configured successfully.

Install phpMyAdmin on CentOS 8

Download latest version of phpMyAdmin from phpMyAdmin official website.

Currently, the phpMyAdmin 5.0.1 is the latest stable release. Therefore, we are downloading it from phpMyAdmin official download page.

# cd /tmp
# wget https://files.phpmyadmin.net/phpMyAdmin/5.0.1/phpMyAdmin-5.0.1-english.tar.gz
--2020-02-05 17:09:13--  https://files.phpmyadmin.net/phpMyAdmin/5.0.1/phpMyAdmin-5.0.1-english.tar.gz
Resolving files.phpmyadmin.net (files.phpmyadmin.net)... 84.17.57.12
Connecting to files.phpmyadmin.net (files.phpmyadmin.net)|84.17.57.12|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8158876 (7.8M) [application/octet-stream]
Saving to: âphpMyAdmin-5.0.1-english.tar.gzâ

phpMyAdmin-5.0.1-en 100%[===================>]   7.78M  1.09MB/s    in 8.0s

2020-02-05 17:09:22 (996 KB/s) - âphpMyAdmin-5.0.1-english.tar.gzâ saved [8158876/8158876]

You can install phpMyAdmin by extracting the downloaded TARBall in Apache default document root.

# tar xf phpMyAdmin-5.0.1-english.tar.gz --directory /var/www/html

Rename extracted directory for better accessibility.

# cd
# mv /var/www/html/phpMyAdmin-5.0.1-english/ /var/www/html/pma

Create phpMyAdmin database and related objects in MariaDB server using a script that was provided by the vendor in phpMyAdmin directory.

# mysql -u root -p123 < /var/www/html/pma/sql/create_tables.sql

Make a copy of sample configuration file.

# cp /var/www/html/pma/config.sample.inc.php /var/www/html/pma/config.inc.php

Edit config.inc.php file in a text editor.

# vi /var/www/html/pma/config.inc.php

Set a 32 character Blowfish secret in this file.

$cfg['blowfish_secret'] = 'I;Am;Fan;0f;0p3n;S0urc3;S0ftwar3'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

Create a temporary directory to cache templates by phpMyAdmin.

# mkdir /var/www/html/pma/tmp

Set apache user as the owner of pma directory.

# chown -R apache:apache /var/www/html/pma/

Set SELinux permissions for tmp directory, to make it writable by the apache user.

# semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/pma/tmp(/.*)?"
# restorecon -Rv /var/www/html/pma/tmp
Relabeled /var/www/html/pma/tmp from unconfined_u:object_r:httpd_sys_content_t:s0 to unconfined_u:object_r:httpd_sys_rw_content_t:s0

Open URL https://phpmyadmin-01.sysadminlabs.com/pma/ in a web browser.

phpMyAdmin Login
phpMyAdmin Login

Login as root user.

phpMyAdmin Dashboard
phpMyAdmin Dashboard

After successful login, you are reached at the Dashboard of phpMyAdmin application.

To start using phpMyAdmin, you should read Mastering phpMyAdmin 3.4 for Effective MySQL Management (PAID LINK) by Packt Publishing.

Final Thoughts

Install phpMyAdmin on CentOS 8 is a great way to streamline the management of your MySQL databases with a user-friendly web interface. With the right steps, you can get phpMyAdmin up and running quickly to make database administration more efficient.

For a detailed, step-by-step guide on how to install phpMyAdmin on CentOS 8, check out my Fiverr gig: How to Install phpMyAdmin on CentOS 8. I offer expert support to ensure your phpMyAdmin setup is smooth and successful.

If you have any questions or need further assistance, feel free to reach out!

2 thoughts on “How to install phpMyAdmin on CentOS 8”

  1. Thank you for this beautiful tutorial, but I had a problem. I have not followed the example from the beginning, because I already had lamp installed. the problem was with SSL. I had to do a "dnf install mod_ssl" to be able to modify the /etc/httpd/conf.d/ssl.conf. There was none before that. I had tried to create it myself, but it didn't work. after installing mod_ssl, the file was there, I was able to modify the 2 lines for the crt and the key. Now it works great! Thank you for your work !

Leave a Comment