Skip to content

How to Disable root Login in phpMyAdmin

This how to guide will help you to restrict root login through phpMyAdmin. Edit its configuation file config.inc.php and update following parameters.

Category
Security
Covers
MySQL, PHP, phpMyAdmin
Versions & support
About MySQL →, About PHP →
On this page

phpMyAdmin is a popular tool used to manage MySQL databases through a web interface. However, allowing root login through phpMyAdmin can pose a security risk because it gives complete control over the database. Disabling root login in phpMyAdmin is a simple yet effective way to protect your system from unauthorized access.

In this guide, we will walk you through easy steps to disable root login, making your phpMyAdmin setup more secure without affecting its functionality for other users.

Disable root Login in phpMyAdmin

First of all, find the phpMyAdmin directory location as per your installation. Generally, it is installed under /usr/share/phpmyadmin directory. In some cases, the configuration file may be located under the /etc/phpmyadmin directory.

Switch to the phpMyAdmin directory:

cd /usr/share/phpmyadmin 

Then edit the config.in.php in that directory. This is the main configuration file used by the phpMyAdmin.

vim config.inc.php 

Now, add/update the following parameters:


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

Some of the default installations may not have the config.inc.php. In that case, you can make a copy of the config.sample.inc.php file at the same location.

cp config.sample.inc.php config.inc.php 

Test Configuration

Open phpMyAdmin in a web browser and try login with the root account. You will see “Access denied!” error message on screen. It means the changes work correctly.

disable root phpmyadmin

Conclusion

Disabling root login in phpMyAdmin is a crucial step in securing your database. By following these steps, you can significantly reduce the risk of unauthorized access. Remember, security is an ongoing process, and it’s important to stay vigilant and keep your systems updated.

Rahul

Rahul Kumar is the founder and chief editor of TecAdmin.net. A Red Hat Certified Engineer (RHCE), he has worked in IT since 2009, with hands-on experience in Linux system administration, DevOps, web hosting, cloud platforms and automation. He started TecAdmin in 2013 to share practical, step-by-step guides, and leads its editorial work with one aim: making technical learning clear and useful for sysadmins, developers and beginners alike.

1 Comment

Leave a Reply

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


Back to top