Reset Mysql root's password

1. Stop Mysql database server

# /etc/init.d/mysql stop

2. Start mysql with skip-grantl-tables (w/o password prompt for root)

# mysqld_safe --skip-grant-tables &

3. Connect to mysql as root:

# mysql -u root

4. Set new password for root

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

 

5. Stop mysql server

# /etc/init.d/mysql stop

6. Start mysql and try to login as root

# /etc/init.d/mysql start
# mysql -u root -p