Force-Resetting the MySQL Root Password Despite Access Denial
You've encountered an issue where you're unable to log in as root, preventing you from changing the MySQL root password.
One effective approach to force-reset the root password involves creating a file containing the following SQL statement:
UPDATE mysql.user SET Password=PASSWORD('newpass') WHERE User='root';
Save this file with an appropriate name, such as "resetPassword.sql."
Next, execute the following command to manually start MySQL with the file you created as the initialization file:
mysqld --init-file=resetPassword.sql
Once the MySQL server starts, it will execute the SQL statement from the file, resetting your password.
After executing the file, shut down the server and restart it normally:
service mysqld stop service mysqld start
You should now be able to log in as root with the new password you provided in the SQL statement.
The above is the detailed content of How to Force-Reset MySQL Root Password When Access is Denied?. For more information, please follow other related articles on the PHP Chinese website!