Home  >  Article  >  Database  >  What to do if you forget your mysql password

What to do if you forget your mysql password

coldplay.xixi
coldplay.xixiOriginal
2020-12-10 15:05:013797browse

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.

What to do if you forget your mysql 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:

What to do if you forget your mysql password

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:

What to do if you forget your mysql password

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!

Statement:
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