Forget
Reset forgotten MySQL root password
Submitted by ravisagar on Tue, 01/08/2008 - 04:08.If you have forgotten your MySQL root password then don't worry. You can reset your lost password. Here is the procedure.
1. Login as root.
2. Kill running MySQL process and stop the MySQL service.
[root@localhost root]# killall mysqld
[root@localhost root]# /usr/libexec/mysqld -Sg --user=root &
3. Restart MySQL server with these parameters
[root@localhost root]# mysqld --skip-grant-tables --user=root
4. Manually set root password in the table "user" of "mysql" database.
[root@localhost root]# mysql
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1 to server version: 3.23.41
Type 'help;' or 'h' for help. Type 'c' to clear the buffer.
mysql> USE mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> UPDATE user
-> SET password=password("newpassword")
-> WHERE user="root";
Query OK, 2 rows affected (0.04 sec)
Rows matched: 2 Changed: 2 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> exit;
[root@localhosthost root]# killall mysqld
5. Restart MySQL again
[root@localhosthost root]# /etc/init.d/mysqld start
Now your root password is set and you can now login as root using the password you have just created.
[root@localhost root]# mysql -u root -p
Enter Password: "newpassword"
If you again forget your root password don't worry just check this link again :)
- ravisagar's blog
- 1 comment
- 1578 reads

Recent comments
2 days 20 hours ago
5 weeks 2 days ago
18 weeks 5 days ago
24 weeks 4 days ago
27 weeks 5 days ago
28 weeks 2 days ago
28 weeks 2 days ago
40 weeks 4 days ago
40 weeks 4 days ago
41 weeks 2 days ago