Solution for forgetting the best mysql password tested
Solution for forgetting the best mysql password tested
The best solution is to forget the mysql password. After testing, if the password fails, your mysql runs abnormally.
Solution:
In windows:
The Code is as follows:
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. The current window will stop.
In addition, open a command line window and execute mysql. If the command is not displayed, first enter the BIN directory of the MYSQL installation location and then run mysql.
> Use mysql
> Update user set password = password ("new_password") 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:
The Code is as follows:
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 password = password ("new_pass") where user = "root ";
> Flush privileges;
Kill MySQL again and start it in normal mode