Changing a forgotten MySQL root password
To change the MySQL root password, use the following steps:
-
Run the following commands:
# /etc/init.d/mysqld stop# mysqld_safe --skip-grant-tables --skip-networking -
Connect to MySQL with the following command:
# mysql -u root -
Run the following command in the MySQL client:
# UPDATE mysql.user SET Password=PASSWORD('newpassword') WHERE User='root'; -
Replace
newpasswordwith your new root password. -
Restart the MySQL server by using the following command:
# /etc/init.d/mysqld start