Wednesday, May 1, 2013

Reset forgotten mysql password


This works for ubuntu/Debain only & not for red hat/Centos

# /etc/init.d/mysql stop
# mysqld_safe --skip-grant-tables &
$ mysql -u root

mysql> use mysql;
mysql> update user set password=PASSWORD("password") where User='root';
mysql> flush privileges;
mysql> quit

# /etc/init.d/mysql stop
# /etc/init.d/mysql start
$ mysql -u root -p
 
Take Full backup of Mysql
mysqldump -u root -ppassword --all-databases > /tmp/all-database.sql 
Restore DB
mysql -u root -ppassword < /tmp/all-database.sql

No comments:

Post a Comment