Tuesday, September 15, 2009

This article is on

How to reset your MySQL Password


1. Stop MySQL server
# service mysql stop
Stopping mysql [ OK ]

2. Start MySQL server in safe mode and fork it to the background
# mysqld_safe --skip-grant-tables -u mysql &
[1] 75725
Starting mysqld daemon with databases from /var/db/mysql

3. Now start mysql
# mysql -u root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 4.1.22

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.


4. Change your password
mysql> update user set Password=password('password') where User='root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0

5. Flush privileges
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

6. Quit
mysql> quit
Bye

7. Restart MySQL server
# service mysql restart
Stopping mysql [ OK ]
Starting mysql [ OK ]

8. Try your new password
# mysql -u root -p mysql
Enter password:

0 comments: