mysql login forgot password, modify (windows10)

My mysql was installed by someone else, and it has been useless for a long time, so no one can remember the password.

1. In order to facilitate opening, close the mysql server and open cmd as an administrator

2. Switch the directory from the default c drive location to the installation directory of mysqld.exe (such as my directory: D:\Program Files\MySQL\MySQL Server 5.7\bin)

Then enter the following command in the dos command

First, if the mysql service is started, close it first, and then change the disk

3. Skip password verification

At this point, there will only be a flash of the cursor and the command cannot continue to be written, so reopen a cmd window

4. Write the following command

After the red number 3 steps, the prefix of the command on each line becomes mysql>, then the passwordless login is correct. But the password needs to be changed after 4 is executed. As shown in the figure, the password field written on the Internet does not exist in the user table, so check the structure of the table (box without numbers)

5. As can be seen from the above, after mysql5.7, the password field has been changed to authentication_string

This is the 45 fields displayed in the user table, of which the password field is selected.

change Password:

Prompt that the modification is successful.

Live: Problems that may be encountered during the period, such as when entering the mysqld -nt.... command and reporting an error saying that it is not an internal or external command, you need to check the system environment variables (bin path of mysql installation in the path, as follows mine), add to path

Also: When starting the Mysql server, an error may be reported saying that the service is closed after it is started, and some services or programs are automatically stopped when not in use... In short, it suddenly fails to start for no reason, then

Delete the service directly: switch the dos command to the bin directory of the mysql installation and write: mysqld.exe service delete mysql (mysql write your own service name)

Re-register the service: mysqld.exe -install

Start the service and try: net start mysql.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324732500&siteId=291194637