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.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3