Home > Database > Mysql Tutorial > body text

How to Reset MySQL Root Password When Access Denied and Traditional Methods Fail?

Susan Sarandon
Release: 2024-10-30 12:00:27
Original
184 people have browsed it

How to Reset MySQL Root Password When Access Denied and Traditional Methods Fail?

How to Reset the MySQL Root Password When Access Denied

This issue arises when attempting to log in to MySQL as the root user proves unsuccessful due to access denial. Subsequently, attempts to set or reset the password using mysqladmin or the --skip-grant-tables method fail.

To overcome this challenge, consider the following alternative:

Save the following SQL statement into a file:

<code class="sql">UPDATE mysql.user SET Password=PASSWORD('newpass') WHERE User='root';</code>
Copy after login

Manually start the MySQL server using the following command:

mysqld --init-file=FILENAME
Copy after login

Replace FILENAME with the name of the file containing the SQL statement.

Upon server startup, the password should be reset to 'newpass.'

Next, shut down the server and restart it normally. You should now be able to log in with the new password.

The above is the detailed content of How to Reset MySQL Root Password When Access Denied and Traditional Methods Fail?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!