How to change MySQL root password in XAMPP localhost ?

The root password for XAMPP is empty by default. The default empty password is obvious for development purpose in local environment. However, if we want to make the database more secure and not easily accessible, we can easily change the MySQL password.

The following are the 2 simple steps to change MySQL password in XAMPP :

Step 1

Run the following query from phpmyadmin where ‘pass’ is the password to be set

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('pass');

Step 2

Set the auth_type to ‘cookie’ in config.inc.php

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

After following the above 2 steps, you will need to provide the password to login to phpmyadmin. Moreover, the database access credentials in any projects should be updated so that the database connection is successful.



Recommended For You

About the Author: Admin