Recover MySQL Database root password

Ploblem: forget MySQL root password
Solutions: Recover(hack) MySQL root password

1. Login as root
2. Stop the MySQL server by using command

/etc/init.d/mysql stop
#or
ps aux | grep mysql
kill -9 mysqlID
3. Start MySQL server without password
mysqld_safe --skip-grant-tables &
#/usr/local/mysql/bin/mysqld_safe --skip-grant-tables &
4.Connect to mysql server using mysql client
mysql -u root
5. Now you need to Setup new MySQL root user password
mysql> use mysql;
mysql> update user set password=PASSWORD("newrootpassword") where user='root';
mysql> flush privileges;
mysql> quit
6. Restart MySQL
/etc/init.d/mysql stop
/etc/init.d/mysql start


Blog | , , ,
Line it!