To make password more secure i choose password with alphabets(small and caps), numeric and symbols (!#..),
and sometimes i end up forgetting such passwords.
Can we recover lost mysql root password or is there any way to change mysql root password?
When i was a fresher i have seen myself when not able to access mysql, i used to uninstall and reinstall mysql server.
Well is there any better way to recover/change/reset mysql root password which is lost? Answer is yes, if you are a sudo user.
Step1: Stop the mysql process
sudo /etc/init.d/mysqld stop
step2: Start mysql in safe mode and skip the check against user privileges.
sudo /usr/bin/mysqld_safe –skip-grant-tables &
Step3: Since mysql is running in safe mode and we have skiped user privileges, now ogin to mysql without using password and use mysql database , update the password and flush the privileges.
mysql -u root
use mysql;
update user set password=PASSWORD(”newpassword”) where User=’root’;
flush privileges;
Step4: Let us test by logging in to mysql using the password. We need to stop the earlier started mysql process which is running in safe mode with user priviliges check being skipped. Now start the mysql in normal mode and try logging in to mysql using the new password.
sudo /etc/init.d/mysqld stop
sudo /etc/init.d/mysqld start
mysql -u root -pnewpassword
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « May | ||||||
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | |||
One Response
Yogananda Naidu T
March 10th, 2010 at 2:30 am
1Thanks Ganesh for Above Information
RSS feed for comments on this post · TrackBack URI
Leave a reply