Home > Database > Mysql Tutorial > How to Reset MySQL Root Password Without the Old Password?

How to Reset MySQL Root Password Without the Old Password?

DDD
Release: 2024-11-06 16:37:02
Original
1014 people have browsed it

How to Reset MySQL Root Password Without the Old Password?

Resetting MySQL Root Password Without Old Password

If you find yourself unable to recall your MySQL root password, regaining access is possible through a series of steps.

To begin, stop the MySQL service using the command:

sudo service mysql stop
Copy after login

Next, start MySQL in safe mode with the following command:

sudo mysqld_safe --skip-grant-tables --skip-syslog --skip-networking
Copy after login

In a new terminal, connect to MySQL as root:

mysql -u root
Copy after login

Execute the following queries to change the root password:

UPDATE mysql.user SET authentication_string=PASSWORD('password') WHERE User='root';
FLUSH PRIVILEGES;
Copy after login

Note: In MySQL 5.7, the password field was replaced by the authentication_string field.

Finally, quit MySQL safe mode and restart the MySQL service:

mysqladmin shutdown
sudo service mysql start
Copy after login

With these steps, you should have reset your MySQL root password successfully.

The above is the detailed content of How to Reset MySQL Root Password Without the Old Password?. 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template