With the multiplication of passwords, it becomes easy to forget crummy and useless passwords like the root password of a MySQL installation (you did set a root passsword, did you ?). Here is an easy procedure in case you forget:
# /etc/init.d/mysql stopSET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpassword');
Obviously, substitute in your desired password (leaving the quotes intact). Save the file as passwordinit.
Now, we need to start the MySQL server with this init file. Still as root on the system, run:
# mysqld_safe --init-file=~/passwordinit &
As soon as you press Enter, the password has been changed. Now I recommend restarting the MySQL server in the normal way, as follows:
# /etc/init.d/mysql restart
And that’s it. Be more careful next time.
Originally published on FOSSwire