Hosting + Ai Website Builder + Free Domain (3 Month Free Credit)
Shop Today

How to Fix phpMyAdmin on Linux Server: Complete Troubleshooting Guide

phpMyAdmin is one of the most popular web-based tools for managing MySQL and MariaDB databases. It simplifies database management tasks, such as creating databases, running queries, and managing users. Administrators may need to fix phpMyAdmin issue in Linux when problems occur, such as configuration errors, connection failures, or issues accessing the web interface. However, phpMyAdmin can sometimes encounter issues that prevent it from functioning properly.

In this article, we will walk you through common phpMyAdmin issues and provide detailed solutions for fixing them. Whether you’re facing installation issues, connection problems, or web interface errors, we’ll guide you through troubleshooting steps to restore phpMyAdmin to full functionality on your Linux server.

Preliminary Steps Before Fixing phpMyAdmin

phpMyAdmin on a Linux Server

Before diving into specific fixes, make sure that phpMyAdmin is installed and configured correctly on your server.

Check the Apache or Nginx Service

phpMyAdmin requires a web server (typically Apache or Nginx) to serve the web interface. First, check if your web server is running.

  • For Apache:
sudo systemctl status apache2
  • For Nginx:
sudo systemctl status nginx

If the web server is not running, start it:

  • For Apache:
sudo systemctl start apache2
  • For Nginx:
sudo systemctl start nginx

Ensure PHP is Installed

phpMyAdmin requires PHP to run. Check if PHP is installed on your system:

php -v

If PHP is not installed, you can install it along with the required extensions:

For Debian/Ubuntu-based systems:

sudo apt-get install php php-mysqli php-xml php-mbstring php-json php-zip

For RHEL/CentOS-based systems:

sudo yum install php php-mysqli php-xml php-mbstring php-json php-zip

Check phpMyAdmin Installation

Ensure that phpMyAdmin is installed by checking if the package is present. You can verify the installation with:

For Debian/Ubuntu-based systems:

dpkg -l | grep phpmyadmin

For RHEL/CentOS-based systems:

rpm -qa | grep phpmyadmin

If phpMyAdmin is not installed, you can install it with:

For Debian/Ubuntu-based systems:

sudo apt-get install phpmyadmin

For RHEL/CentOS-based systems:

sudo yum install phpmyadmin

Identifying Common phpMyAdmin Issues

Several issues may arise when using phpMyAdmin. Below are some of the most common problems:

  • phpMyAdmin Web Interface Not Accessible

If you can’t access the phpMyAdmin web interface via the browser, it could be due to several reasons, including web server issues, configuration problems, or firewall restrictions.

  • phpMyAdmin Login Failure

If phpMyAdmin is throwing a login error, such as “Access denied for user,” it could be due to incorrect MySQL/MariaDB credentials, incorrect configuration, or permission issues.

  • phpMyAdmin Showing “Forbidden” Error

If you see a “Forbidden” or “403 Forbidden” error when trying to access phpMyAdmin, it could be caused by Apache or Nginx misconfiguration or permission issues with the phpMyAdmin directory.

  • phpMyAdmin 500 Internal Server Error

A “500 Internal Server Error” usually indicates a server-side issue, which could be caused by PHP errors, missing dependencies, or misconfigurations in the phpMyAdmin configuration files.

Fixing phpMyAdmin on Linux: Step-by-Step Solutions

Once you’ve identified the issue, follow these steps to fix phpMyAdmin on your Linux server.

Restart Apache or Nginx Web Server

If phpMyAdmin is not loading, try restarting your web server to see if it resolves the issue.

For Apache:

sudo systemctl restart apache2

For Nginx:

sudo systemctl restart nginx

Check if the phpMyAdmin interface is accessible after the restart.

Check phpMyAdmin Configuration Files

Configuration issues in phpMyAdmin’s configuration files can prevent the tool from working properly. Check the following files:

  • Apache configuration:

Ensure that the phpmyadmin.conf file exists and is properly configured.

On Ubuntu/Debian systems, the file is typically located in /etc/apache2/conf-available/phpmyadmin.conf. To enable it, run:

sudo a2enconf phpmyadmin sudo systemctl reload apache2
  • phpMyAdmin configuration file:

Ensure that config.inc.php is properly configured. The file is usually located in /etc/phpmyadmin/ or /usr/share/phpmyadmin/. Ensure that the $cfg['Servers'][$i]['auth_type'] is set to cookie, which is the most common setting for authentication:

$cfg['Servers'][$i]['auth_type'] = 'cookie';

If using cookie authentication, phpMyAdmin will prompt for the MySQL/MariaDB username and password when logging in.

Verify MySQL/MariaDB User Permissions

If you’re getting a “Access Denied” or “Login Failed” error, it’s likely due to incorrect credentials or insufficient privileges for the MySQL/MariaDB user. To verify and adjust the permissions:

  • Log in to MySQL/MariaDB as root:
sudo mysql -u root -p
  • Grant the necessary privileges (replace username and password with the actual MySQL user and password for phpMyAdmin):
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password'; FLUSH PRIVILEGES;
  • Test the credentials:

Log in to phpMyAdmin with the username and password to verify that the login works.

Check for Firewall Restrictions

If phpMyAdmin is not accessible from a browser, it could be blocked by a firewall. Check if the server firewall is blocking the HTTP/HTTPS traffic (port 80/443).

For UFW (Uncomplicated Firewall) on Ubuntu/Debian-based systems, run:

sudo ufw allow 80,443/tcp

For firewalld on RHEL/CentOS-based systems:

sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
sudo firewall-cmd --zone=public --add-port=443/tcp --permanent
sudo firewall-cmd --reload

Check PHP Settings

phpMyAdmin requires PHP to function, and incorrect PHP settings can cause errors such as “500 Internal Server Error” or “Forbidden”. Ensure that PHP is installed and properly configured.

  • Check PHP version:
php -v
  • Verify PHP modules:

phpMyAdmin requires several PHP modules, such as php-mysqli, php-xml, and php-mbstring. Check if the necessary modules are installed:

For Debian/Ubuntu-based systems:

sudo apt-get install php-mysqli php-xml php-mbstring php-json php-zip

For RHEL/CentOS-based systems:

sudo yum install php-mysqli php-xml php-mbstring php-json php-zip
  • Check PHP configuration:

Ensure that PHP’s max_execution_time, upload_max_filesize, and memory_limit settings are high enough to avoid timeout or memory issues. These can be modified in /etc/php/7.x/apache2/php.ini (adjust for your PHP version).

For example:

max_execution_time = 300 
upload_max_filesize = 50M 
memory_limit = 256M
  • Restart Apache to apply the changes:
sudo systemctl restart apache2

Fix 403 Forbidden Error

If you encounter a “403 Forbidden” error, it may be caused by incorrect directory or file permissions. To fix this:

  • Ensure the correct ownership and permissions for the phpMyAdmin files:
sudo chown -R www-data:www-data /usr/share/phpmyadmin sudo chmod -R 755 /usr/share/phpmyadmin
  • Ensure the web server has permission to access phpMyAdmin:

Check that the Apache/Nginx configuration allows access to phpMyAdmin.

For Apache, make sure the phpmyadmin.conf file exists in the conf-available directory:

sudo a2enconf phpmyadmin sudo systemctl reload apache2

Fix 500 Internal Server Error

A 500 error may be caused by a PHP issue, a misconfiguration, or a missing dependency. Follow these steps:

  • Check the Apache error log for detailed information:
sudo tail -f /var/log/apache2/error.log
  • Enable PHP error logging by modifying the php.ini file:
display_errors = On log_errors = On error_log = /var/log/php_errors.log
  • Then, restart Apache:
sudo systemctl restart apache2
  • Check the PHP version and ensure it’s compatible with phpMyAdmin.

Reinstall phpMyAdmin

If issues persist, reinstalling phpMyAdmin can help resolve missing files or corrupted configurations. First, remove the existing phpMyAdmin package:

For Debian/Ubuntu-based systems:

sudo apt-get remove --purge phpmyadmin

For RHEL/CentOS-based systems:

sudo yum remove phpmyadmin

Then, reinstall phpMyAdmin:

For Debian/Ubuntu-based systems:

sudo apt-get install phpmyadmin

For RHEL/CentOS-based systems:

sudo yum install phpmyadmin

Conclusion

Fixing phpMyAdmin on a Linux server involves troubleshooting common issues such as service failures, login problems, or misconfigurations. By following the solutions outlined in this guide, you can resolve most phpMyAdmin issues and ensure that it works smoothly for managing your databases. Regularly monitor the logs, review configuration files, and ensure that PHP, MySQL, and your web server are properly configured to maintain a reliable and secure phpMyAdmin installation.

Himanshu Joshi

Leave a Comment

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

Scroll to Top