Blog

How to change the MySQL root password

February 17, 2020 Blog
How to change the MySQL root password

Almost every time I work in a new environment, I prefer to change the MySQL root password. Maybe that is just my paranoia. Since I always end up searching for the syntax because I forget it, I am leaving it documented here. It may help someone.

This command can be used from the command line or directly in PhpMyAdmin.

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('NEWPASSWORD'); FLUSH PRIVILEGES;

Right after that, when you try to access PhpMyAdmin, you should see an error message. The reason is that the configuration file needs to be updated with the new password. The file is config-inc.php, inside the PhpMyAdmin folder.

$cfg['Servers'][$i]['password'] = 'NEWPASSWORD';

That way, MySQL will be updated with the new password.

Comments

Join the conversation

Loading comments...