Fix phpMyAdmin Permission Denied on Fedora
In this article
If you’re seeing “Access denied for user” or “Permission denied” when trying to open phpMyAdmin on Fedora, it usually means the web server can’t read the config file, or PHP can’t connect to MariaDB/MySQL with the credentials you set. This guide walks you through the most common causes—file ownership, SELinux contexts, and database user privileges—and shows you how to fix each one. You’ll need sudo access to your Fedora machine and a terminal.
What You’ll Need
- Fedora workstation or server (version 38 or later)
- Root or sudo access
- phpMyAdmin already installed (via
dnf install phpMyAdmin) - MariaDB or MySQL server running
Step-by-Step
- Check the phpMyAdmin file permissions.
The default install puts files in/usr/share/phpMyAdmin. The web server (Apache, usually running as userapache) needs read access. Run:
sudo ls -l /usr/share/phpMyAdmin
If files are owned by root and not world-readable, fix with:
sudo chown -R root:apache /usr/share/phpMyAdmin
sudo chmod -R 755 /usr/share/phpMyAdmin - Verify the config file is readable.
The main config is/etc/phpMyAdmin/config.inc.php. Ensure it’s readable by the web server:
sudo chmod 644 /etc/phpMyAdmin/config.inc.php
If you use a custom config, check its permissions too. - Check SELinux booleans.
Fedora ships with SELinux enforcing. phpMyAdmin needs thehttpd_can_network_connect_dbboolean enabled to connect to the database over TCP. Run:
sudo setsebool -P httpd_can_network_connect_db on
Also, if your config file is in a non-standard location, you may need:
sudo setsebool -P httpd_read_user_content on - Check SELinux file contexts.
If you moved or created a config file, it might have the wrong context. Restore defaults with:
sudo restorecon -Rv /etc/phpMyAdmin /usr/share/phpMyAdmin - Verify the database user credentials.
The most common “permission denied” is from MySQL itself. Edit the config file:
sudo nano /etc/phpMyAdmin/config.inc.php
Look for lines like:
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
Change them to a valid MySQL user. If you want to use root, you must set a password for root in MySQL first. - Create a dedicated MySQL user.
Instead of root, create a user with privileges:
sudo mysql -u root -p
Then run:
CREATE USER 'phpmyadmin'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Update the config file with these credentials. - Restart the web server.
After any change, restart Apache:
sudo systemctl restart httpd - Clear browser cache and cookies.
Sometimes stale sessions cause issues. Try a different browser or incognito mode.
Common Mistakes
- Forgetting SELinux. Many Fedora users disable SELinux or skip the boolean, which leads to persistent denials even with correct file permissions.
- Using root with no password. By default, MariaDB root uses unix_socket auth, so phpMyAdmin can’t log in with an empty password.
- Editing the wrong config file. phpMyAdmin also reads
/etc/phpMyAdmin/config.inc.phpand sometimes/etc/phpMyAdmin/config.inc.php.local. Make sure you edit the one that’s actually loaded. - Changing file ownership to the wrong user. On Fedora, Apache runs as
apache, notwww-data(that’s Debian). Using the wrong user will cause permission errors.
Tips
- Always use a dedicated MySQL user for phpMyAdmin, not root. It’s safer and avoids auth plugin conflicts.
- Use strong passwords and store them in a protected file. The config file is readable only by root and apache, so keep permissions tight (640).
- If you’re on a headless server, test with
curl -I http://localhost/phpMyAdminto see if the page loads without browser interference. - Keep SELinux enforcing—it’s not the enemy. Just set the correct booleans.
Troubleshooting
If you still get “Permission denied” after following all steps:
- Check the Apache error log:
sudo tail -f /var/log/httpd/error_log. It will show the exact file or connection that’s denied. - If the error mentions
/etc/phpMyAdmin/config.inc.php, the file might be unreadable by Apache. Runsudo chmod 644on it. - If the error is from MySQL (e.g., “Access denied for user ‘phpmyadmin’@‘localhost’”), double-check the password and host in the config. Also ensure the MySQL user exists and has privileges.
- If you see SELinux denials in
sudo ausearch -m avc -ts recent, you can temporarily set enforcing to permissive to test:sudo setenforce 0. If the page works, re-enable and adjust booleans. - If the page loads but shows a blank white screen, check PHP errors:
sudo tail -f /var/log/php-fpm/www-error.log(if using PHP-FPM).
Frequently Asked Questions
Why does phpMyAdmin work on Ubuntu but not Fedora?
Fedora enforces SELinux by default, which adds an extra layer of access control. Ubuntu uses AppArmor, which is less strict for web apps. The SELinux booleans mentioned above are the usual fix.
Can I just disable SELinux to fix it?
You can, but it’s not recommended. Disabling SELinux reduces security. Instead, set the correct boolean or restore contexts. If you must, use sudo setenforce 0 temporarily to test, then re-enable.
What is the default MySQL root password on Fedora?
There isn’t one. MariaDB on Fedora uses unix_socket authentication for root, meaning only system root can log in via the socket. To set a password, run sudo mysql -u root and then ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpass';
Which user does Apache run as on Fedora?
Apache runs as the apache user. That’s why file ownership should be root:apache for web-readable files.
How do I find the exact phpMyAdmin config file being used?
Run php -i | grep 'Loaded Configuration' for PHP, but for phpMyAdmin, the file is always /etc/phpMyAdmin/config.inc.php unless you’ve overridden it. Check /etc/phpMyAdmin/ for any .inc.php files.
I get “Cannot load mysqli extension” – what now?
Install the PHP MySQL extension: sudo dnf install php-mysqlnd and restart Apache. That’s separate from permission issues, but common after a fresh install.