General
MySQL: Reset Root Database User’s Password
Posted on .Here are the commands you need to execute to change a forgotten MySQL root user password:
Step # 1 : Stop the MySQL service:
# /etc/init.d/mysql stop
Step # 2: Start the MySQL server w/o password:
# mysqld_safe --skip-grant-tables &
Step # 3: Connect to the MySQL server using the MySQL client:
# mysql -u root
Step # 4: Set a new MySQL root user password:
mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> /q
Step # 5: Stop the MySQL server:
# /etc/init.d/mysql stop
Start the MySQL server and test it:
# /etc/init.d/mysql start
# mysql -u root -p