Ever tried losing your MySQL root password, because you’re an idiot or a coworker changed it without documenting or telling?
Well, within 10 minutes this can be fixed. This guide applies to Debian and probably others too. su – to root and perform the following.
1. Stop MySQL
2. Start MySQL and skip grant tables, put it to background so you can work
mysqld_safe –skip-grant-tables &
3. Enter MySQL as root
mysql -u root
4. Change the password within the MySQL console
mysql> use mysql;
mysql> update user set password=PASSWORD(“insert-new-password-here”) where User=’root’;
mysql> flush privileges;
5. Stop MySQL server again
– Now if that did not work, find the MySQL process with ps and kill it.
6. Start MySQL again
And it should work.. test it by typing “mysql -u root -p” and enter the password you just created.