Reset forgotten mysql root password

Here is the steps to reset mysql password in case of one forget it.
Note: One must have linux root login credential.

Step 1:
Open a terminal, and login using root linux password. Firstly, stop mysql daemon, using the below command:
/etc/init.d/mysql stop
or,
service mysql stop
Step 2:
Start the mysql server manually without permission of tables which will allow to login as root user without password. Use the following command:
mysqld_safe --skip-grant-tables
120730 08:53:40 mysqld_safe Logging to '/var/lib/mysql/MBS-APPS.err'.
120730 08:53:40 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Step 3:
Now open a new window and start mysql without any password:
mysql --user=root mysql
Step 4:
Now reset the mysql root password,
UPDATE user SET password=PASSWORD('newpassword') WHERE user='root';
flush privileges;
exit;
Step 5:
Password will successfully reset. Now kill all mysqld process.
ps -ef|grep -i mysql 
kill -9 pid1 pid2 
Step 6:
Finally, root password reset. start mysql service.
service mysql start  

Comments

Popular posts from this blog

attach file gives false disk address path as 'C:/fakepath/filename'

Ajmer tour on 18th June '11

How to fix World-writable config file /etc/my.cnf is ignored?