phpMyAdmin is a free and open-source web application that serves as a powerful interface for managing MySQL databases. It simplifies database administration tasks, making it an essential tool for web developers, database administrators, and anyone working with MySQL. This guide will walk you through the process of installing phpMyAdmin, ensuring you have a robust and accessible database management environment.
Prerequisites for Installation
Before embarking on the phpMyAdmin installation journey, it’s crucial to have a foundational understanding of the environment it operates within. phpMyAdmin, at its core, is a web application that interacts with a MySQL database server. Therefore, the successful installation and operation of phpMyAdmin are contingent upon the proper setup and configuration of its dependencies.

Web Server Environment
phpMyAdmin requires a web server capable of executing PHP scripts. The most common and widely recommended choice is the Apache HTTP Server. However, Nginx, Lighttpd, and other compatible web servers can also be utilized. The web server must be installed and running correctly on your system. Key considerations for your web server include:
- PHP Support: The web server must be configured to process PHP files. This typically involves installing and enabling the PHP interpreter and relevant modules for your chosen web server. For Apache, this usually means installing
mod_phpor configuring FastCGI with PHP-FPM. For Nginx, PHP-FPM is the standard approach. - Web Server Configuration: Ensure your web server’s configuration allows access to the directory where phpMyAdmin will be installed and that it correctly routes requests for PHP files to the interpreter.
MySQL Database Server
The primary function of phpMyAdmin is to manage MySQL databases. Consequently, a running MySQL or MariaDB server is a non-negotiable prerequisite.
- Installation and Configuration: MySQL or MariaDB must be installed and operational on your system. This includes setting up root credentials for database administration.
- Access Permissions: The web server user (the user under which your web server runs) will need appropriate permissions to connect to the MySQL server and manage databases. This typically involves creating a dedicated MySQL user for phpMyAdmin with the necessary privileges.
PHP Installation and Configuration
phpMyAdmin is written in PHP, making PHP a critical dependency. The version of PHP installed on your system must be compatible with the version of phpMyAdmin you intend to install. Consult the official phpMyAdmin documentation for specific version compatibility.
-
PHP Version Compatibility: Always check the phpMyAdmin release notes for the minimum and recommended PHP versions. Installing an incompatible PHP version can lead to errors and unexpected behavior.
-
Required PHP Extensions: phpMyAdmin relies on several PHP extensions to function correctly. The most important ones include:
mbstring: For multibyte string handling, crucial for internationalization and character set support.mysqli: The improved MySQL extension for PHP, used for connecting to and interacting with MySQL databases.json: For JSON data serialization and deserialization.gd(optional but recommended): For generating graphical representations of data, such as charts and graphs.curl(optional): For interacting with external resources.zip(optional): For handling ZIP archives.
Ensure these extensions are enabled in your PHP configuration (
php.inifile). You can verify installed extensions by creating a simple PHP file with<?php phpinfo(); ?>and accessing it via your web browser.
System Requirements
While phpMyAdmin is relatively lightweight, it’s important to ensure your system has sufficient resources.
- Disk Space: phpMyAdmin itself requires minimal disk space. However, the databases you manage will occupy storage.
- Memory: Adequate RAM is necessary for the web server, PHP interpreter, and MySQL server to operate smoothly, especially when managing large databases or performing complex operations.
Installation Methods
There are several methods to install phpMyAdmin, each offering different advantages depending on your operating system and package management preferences.
Method 1: Using a Package Manager (Recommended)
This is the most straightforward and recommended method for most users, especially those running Linux distributions. Package managers handle dependencies automatically, simplifying the installation process.
For Debian/Ubuntu-based Systems (apt)
-
Update Package Lists:
Before installing any new software, it’s good practice to update your system’s package lists to ensure you’re getting the latest available versions.sudo apt update -
Install phpMyAdmin:
The phpMyAdmin package is usually available in the default repositories.sudo apt install phpmyadminDuring the installation, you will be prompted with a configuration screen.
- Web Server Selection: You’ll be asked to choose a web server to configure for phpMyAdmin. Select
apache2(ornginxif you have it installed and configured for PHP). PressSpacebarto select andTabto move toOk. - Database Configuration: You will be asked if you want to configure the database for phpMyAdmin with
dbconfig-common. It is highly recommended to selectYes. This will automatically create a dedicated database and user for phpMyAdmin. - phpMyAdmin Application Password: You will be prompted to enter a password for phpMyAdmin to register with the database. Create a strong password and remember it, as you’ll use this to log into phpMyAdmin.
- Web Server Selection: You’ll be asked to choose a web server to configure for phpMyAdmin. Select
-
Apache Configuration (if selected):
If you selected Apache, the package manager will attempt to automatically configure Apache to serve phpMyAdmin. It usually does this by creating an alias, making phpMyAdmin accessible at a URL likehttp://your_server_ip_or_domain/phpmyadmin. -
Nginx Configuration (if selected):
If you chose Nginx, you might need to perform some manual configuration. The installation process might create a configuration file for Nginx, often located in/etc/nginx/sites-available/phpmyadmin.conf. You’ll then need to symlink this to yoursites-enableddirectory and restart Nginx.sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf sudo a2enconf phpmyadmin sudo systemctl reload apache2 # Or for Nginx (example, paths might vary) # sudo cp /etc/phpmyadmin/nginx.conf /etc/nginx/sites-available/phpmyadmin # sudo ln -s /etc/nginx/sites-available/phpmyadmin /etc/nginx/sites-enabled/ # sudo systemctl reload nginx -
Install PHP Extensions (if needed):
The package installation usually pulls in necessary PHP extensions. However, if you encounter issues, you might need to install them manually:sudo apt install php-mbstring php-mysqli php-json php-gdAfter installing extensions, restart your web server.
For RHEL/CentOS/Fedora-based Systems (yum/dnf)
-
Enable EPEL Repository:
phpMyAdmin is typically found in the Extra Packages for Enterprise Linux (EPEL) repository. You need to enable this repository first.sudo yum install epel-release # Or for newer Fedora/RHEL versions: # sudo dnf install epel-release -
Install phpMyAdmin:
sudo yum install phpmyadmin # Or for newer Fedora/RHEL versions: # sudo dnf install phpmyadmin -
Configure Web Server:
Unlike Debian/Ubuntu, the package manager might not automatically configure your web server. You’ll likely need to manually adjust Apache or Nginx configuration.-
For Apache:
The installation might create a configuration file like/etc/httpd/conf.d/phpMyAdmin.conf. Ensure this file exists and contains directives to allow access to phpMyAdmin. You might need to edit theRequire iporAllow fromdirectives to permit access from your IP address or network.Alias /phpmyadmin /usr/share/phpmyadmin <Directory /usr/share/phpmyadmin> AddDefaultCharset UTF-8<IfModule mod_authz_core.c> # Apache 2.4 Require local </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>
You’ll need to modify
Require localorAllow fromto include your IP address or network range.Restart Apache:
sudo systemctl restart httpd -
For Nginx:
You’ll need to create a server block in Nginx configuration that points to the phpMyAdmin installation directory and sets up PHP processing.
-
-
Install PHP Extensions:
Ensure you have the necessary PHP extensions.sudo yum install php-mbstring php-mysqli php-json php-gd # Or for newer Fedora/RHEL versions: # sudo dnf install php-mbstring php-mysqli php-json php-gdRestart your web server after installing extensions.
Method 2: Manual Installation from Source
This method offers the most control but requires more manual configuration. It’s useful if you need the absolute latest version or are working in an environment where package managers are not preferred.
-
Download phpMyAdmin:
Visit the official phpMyAdmin website (www.phpmyadmin.net) and download the latest stable release archive (usually a.tar.gzor.zipfile). -
Extract the Archive:
Extract the downloaded archive to a directory accessible by your web server. A common location is/var/www/html/or/usr/share/nginx/html/.# Example for a tar.gz file sudo tar xzf phpmyadmin-X.Y.Z-all-languages.tar.gz -C /var/www/html/Replace
phpmyadmin-X.Y.Z-all-languages.tar.gzwith the actual filename and/var/www/html/with your web server’s document root.

-
Rename the Directory:
For easier access, rename the extracted directory tophpmyadmin.sudo mv /var/www/html/phpmyadmin-X.Y.Z-all-languages /var/www/html/phpmyadmin -
Create Configuration Directory:
Create a configuration directory for phpMyAdmin.sudo mkdir /etc/phpmyadmin -
Copy Sample Configuration File:
Copy the sample configuration file and rename it toconfig.inc.php.sudo cp /var/www/html/phpmyadmin/config.sample.inc.php /var/www/html/phpmyadmin/config.inc.php -
Generate a Blowfish Secret:
phpMyAdmin uses a Blowfish secret for cryptographic purposes. You can generate one using a tool or online generator. For example, using PHP:sudo nano /var/www/html/phpmyadmin/config.inc.phpFind the line that starts with
$cfg['blowfish_secret']and uncomment it, then add your generated secret. A good way to generate one is:openssl rand -base64 32Paste the output into the
config.inc.phpfile. -
Configure Server Details (Optional but Recommended):
Inconfig.inc.php, you can specify details about your MySQL server. For local installations, you might want to set:$cfg['Servers'][$i]['host'] = 'localhost'; // or your MySQL server IP/hostname $cfg['Servers'][$i]['port'] = '3306'; // default MySQL port $cfg['Servers'][$i]['user'] = 'pma_user'; // A dedicated user for phpMyAdmin $cfg['Servers'][$i]['password'] = ''; // Leave empty to be prompted -
Set File Permissions:
Ensure that the web server has read and write access to the phpMyAdmin directory.sudo chown -R www-data:www-data /var/www/html/phpmyadmin # For Debian/Ubuntu Apache # Or for Nginx: # sudo chown -R nginx:nginx /var/www/html/phpmyadminAdjust the user and group (
www-data,nginx,apache) based on your web server setup. -
Configure Web Server:
You’ll need to configure your web server to point to thephpmyadmindirectory.-
For Apache: Create an alias in your Apache configuration.
Alias /phpmyadmin /var/www/html/phpmyadmin <Directory /var/www/html/phpmyadmin> Options FollowSymLinks DirectoryIndex index.php AllowOverride All Require local # Or your specific IP/network </Directory>Reload Apache:
sudo systemctl reload apache2 -
For Nginx: Create a server block configuration.
server { listen 80; server_name your_domain.com; # or your IP address root /var/www/html; index index.php index.html index.htm;location /phpmyadmin { index index.php; try_files $uri $uri/ /phpmyadmin/index.php?$args; } location ~ .php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # Adjust PHP version as needed fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # Add security restrictions if desired # location ~ /phpmyadmin/(setup|libraries|classes|config|ps.php) { # deny all; # }}
Reload Nginx:
sudo systemctl reload nginx
-
-
Install Required PHP Extensions:
Ensure the necessary PHP extensions (mbstring,mysqli,json,gd) are installed and enabled.
Post-Installation Configuration and Security
Once phpMyAdmin is installed, a few crucial steps are needed to ensure its optimal and secure operation.
Securing Access to phpMyAdmin
By default, phpMyAdmin might be accessible to anyone who can reach your web server. Implementing security measures is paramount to protect your databases.
Restricting Access by IP Address
The most common security measure is to restrict access to phpMyAdmin to specific IP addresses or networks.
-
Apache: Edit your Apache configuration for phpMyAdmin (e.g., in
/etc/apache2/conf-available/phpmyadmin.confor within a virtual host file). Modify theRequiredirective (Apache 2.4) orAllow fromdirective (Apache 2.2) to specify trusted IP addresses or ranges.# For Apache 2.4 Require ip 192.168.1.0/24 your_static_ip# For Apache 2.2 Allow from 192.168.1.0/24 your_static_ip -
Nginx: Modify the
locationblock for phpMyAdmin in your Nginx configuration.location /phpmyadmin { # ... other directives allow 192.168.1.0/24; # Allow specific IP range allow your_static_ip; # Allow a specific IP deny all; # Deny all others # ... rest of configuration }
Using HTTP Basic Authentication
For an additional layer of security, you can configure HTTP Basic Authentication for the phpMyAdmin directory. This requires users to enter a username and password before they even reach the phpMyAdmin login page.
-
Create a Password File:
Use thehtpasswdutility to create a password file.sudo htpasswd -c /etc/apache2/.htpasswd your_usernameYou’ll be prompted to enter a password for
your_username. For Apache, place this file outside your web root. -
Configure Web Server:
-
Apache: Add directives to your phpMyAdmin configuration to use the password file.
<Directory /var/www/html/phpmyadmin> # ... other directives AuthType Basic AuthName "Restricted Access" AuthUserFile /etc/apache2/.htpasswd Require valid-user </Directory> -
Nginx: This is more complex and often involves using
auth_basicandauth_basic_user_file.
-
Changing the phpMyAdmin URL
Obscuring the default /phpmyadmin URL can deter automated bots and casual attackers. You can achieve this by changing the Alias directive in Apache or the location block in Nginx. For example, change Alias /phpmyadmin to Alias /mysecretadmin.
Creating a Dedicated MySQL User for phpMyAdmin
Using the MySQL root user to log into phpMyAdmin is a security risk. It’s best practice to create a dedicated MySQL user with specific privileges for phpMyAdmin.
-
Log in to MySQL as root:
sudo mysql -u root -p -
Create a User:
Replace'pma_user'and'your_strong_password'with your desired username and a strong password.CREATE USER 'pma_user'@'localhost' IDENTIFIED BY 'your_strong_password'; -
Grant Privileges:
Grant necessary privileges to this user. The exact privileges depend on what you intend to do with phpMyAdmin. A common set includesALL PRIVILEGESon all databases, but you can restrict this further.GRANT ALL PRIVILEGES ON *.* TO 'pma_user'@'localhost' WITH GRANT OPTION; FLUSH PRIVILEGES; EXIT;If you want to restrict access to specific databases, replace
*.*withdatabase_name.*. -
Update phpMyAdmin Configuration:
If you are manually installing, editconfig.inc.phpand set:$cfg['Servers'][$i]['user'] = 'pma_user'; $cfg['Servers'][$i]['password'] = 'your_strong_password';If you used
dbconfig-commonduring package installation, it might have already created a user and configured phpMyAdmin to use it.
Enabling HTTPS
Encrypting the connection between your browser and the web server is crucial, especially when transmitting credentials. If you are serving phpMyAdmin over the internet, setting up SSL/TLS is a must. You can obtain a free SSL certificate from Let’s Encrypt.

Final Checks
- Access phpMyAdmin: Open your web browser and navigate to your phpMyAdmin URL (e.g.,
http://your_server_ip_or_domain/phpmyadmin). - Log In: Use your MySQL credentials (or the dedicated
pma_user) to log in. - Test Functionality: Try creating a new database, a table, and inserting some data to ensure everything is working as expected.
- Review Logs: Check your web server’s error logs (e.g.,
/var/log/apache2/error.logor/var/log/nginx/error.log) and PHP-FPM logs for any unusual messages or errors related to phpMyAdmin.
By following these installation and security steps, you will have a fully functional and secure phpMyAdmin instance ready to manage your MySQL databases efficiently.
