Tuesday, October 20, 2009

Ubuntu: How to reset MySQL password?

Problem: Forgot the password to login mysql.
Solution: Need to reset password.
First, just take few minute checking the default password in file debian.cnf

Command line: sudo gedit /etc/mysql/debian.cnf

Then type this command;
mysql -u debian-sys-maint -p
Enter password:
*Please enter the password stated in the debian.cnf

Then when you logged-in,
mysql >

Type the command to set new password.

Mysql > SET PASSWORD for 'root'@'localhost'= 'my_new_password';

exit.

Then test the new password.
mysql -u root -p
Enter password: my_new_password

---------------------------------------------------

Have a nice day!