The following articles mainly describe how to solve the problem of forgetting the password of MySQL during actual operations. If you forget the password of MySQL during actual operations, the following articles are meaningful to you. The following describes the main content of the article.
In windows: Open the command line window and stop the mysql service: Net stop mysql
Start mysql, usually to the installation path of mysql, find the mysqld-nt.exe
Run: mysqld-nt -- skip-grant-tables
Open a command line window and execute mysql
- >use mysql
- >update user set passwordpassword=password("new_pass") where user="root";
- >flush privileges;
- >exit
Use Ctrl + Alt + Del to find the mysqld-nt process and kill it. After restarting the mysql-nt service, you can log on with the new password.
In linux:
If MySQL is running, killall-TERM mysqld is first killed.
Start MySQL: bin/safe_mysqld -- skip-grant-tables &
You can access MySQL without a password.
Then
- >use mysql
- >update user set passwordpassword=password("new_pass") where user="root";
- >flush privileges;
Kill MySQL again and start MySQL in a normal way. The above content is an introduction to the MySQL password-missing solution. I hope you will get some benefits.
The above content describes how to solve the problem of forgetting the password of MySQL. I hope it will help you in this regard.