Home >Database >Mysql Tutorial >What to do if you forget your mysql password
The solution to forgotten mysql password: first find the configuration file and add [skip-grant-tables]; then restart the mysql service, log in without a password, and enter the terminal; finally change it to your own password.
The operating environment of this tutorial: windows7 system, mysql8.0.22 version, thinkpad t480 computer.
Free recommendation: mysql tutorial(Video)
mysql password forgotten Solution:
Step 1: Find the configuration file in the mysql installation directory, usually my.ini. And under the [mysqld] item, add skip-grant-tables
, and then save the file. The operation is as follows:
Step 2: Restart the mysql service. You can right-click on my computer –> Services – > to find the mysql service and restart it.
Step 3: Log in without a password, enter the terminal, type the mysql -u root -p
command and press Enter, then you can directly enter
Step 4 : Change it to your own password and enter set password for 'username'@'host' = password('newpassword')
in the terminal.
Note: If after typing like mysql -u root -p
, the following picture is displayed:
This indicates that there is no Start the mysql database. Right-click on My Computer->Service->find the mysql service and start it. Or you can start it by typing net start mysql directly in the terminal.
Related free recommendations: Programming video courses
The above is the detailed content of What to do if you forget your mysql password. For more information, please follow other related articles on the PHP Chinese website!