Get the App
SLTechnology News&Howtos  ›  Database  › 

The solution of mysql forgetting his password

Shulou Source: shulou.com Published: 2022-05-31 22:31:37 10月01日 Update

This article will explain in detail the solution to forget your password in mysql. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Mysql's solution to forgetting your password: first find the "my.ini" file; then add "skip-grant-tables" under "mysqld"; then restart the mysql service; and finally reset the password through update.

The operating environment of this article: Windows7 system, Dell G3 computer, MySQL Server 5.7.

What if mysql forgets his password?

When we install and use MySQl, we may not be able to avoid forgetting your password. If you forget your password, you can follow the following procedure:

Find the my.ini file

My.ini file sets the file for MySQl, if you are the default installation address, the file is in the

C:\ ProgramData\ MySQL\ MySQL Server 5.7

But ProgramData is normally hidden.

Set permission authentication to skip

That is, add skip-grant-tables under [mysqld]

Skip-grant-tables

Restart the mysql service

Here you can enter continuously on the command line or find the mysql service restart in the service.

Net stop mysql net start mysql

After reboot, log in as mysql-uroot-p

We will find that we can log in without a password.

Mysql-uroot-p

Reset password

First select the mysql database

Use mysql

Then update password

Update user set authentication_string = password ('new-password') where user =' root'

Note: what you want to change here is the authentication_string, not the password field.

Input

Update user set Password=password ('new-password') where user='root'

Will report an error: ERROR 1054 (42S22): Unknown column 'password' in' field list'

The reason is that there is no password field under the mysql database, and the password field has been changed to authentication_string

Remove the added skip-grant-tables from the my.ini file

Restart the mysql service

Log in with a new password

This is the end of this article on "the solution to mysql forgetting your password". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: Password file service field article login method data database more input good practical that is content method reason command address general Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Tech Info Apple OPPO Reno NVidia