First of all, the first thing you must do is to stop the mysql service first, stop it in the service, or you can stop it with the cmd command, I stop it directly from the service as follows:
My mysql installation directory: C:\Program Files\MySQL\MySQL Server 5.7\bin\, According to the tutorial on the Internet, I used the cmd command to enter the bin folder of mysql, and then executed:
No way. The error report after execution is as follows, the situation of Shenma ???
mysqld: Can't change dir to 'C:\Program Files\MySQL\MySQL Server 5.7\data\' (Errcode: 2 - No such file or directory) 2017-05-25T01:26:39.139544Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2017-05-25T01:26:39.139544Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled 2017-05-25T01:26:39.142318Z 0 [Note] mysqld (mysqld 5.7.17) starting as process 11960 ... 2017-05-25T01:26:39.161559Z 0 [Warning] Can't create test file C:\Program Files\MySQL\MySQL Server 5.7\data\DESKTOP-7IAJK37.lower-test 2017-05-25T01:26:39.162538Z 0 [Warning] Can't create test file C:\Program Files\MySQL\MySQL Server 5.7\data\DESKTOP-7IAJK37.lower-test 2017-05-25T01:26:39.163179Z 0 [ERROR] failed to set datadir to C:\Program Files\MySQL\MySQL Server 5.7\data\ 2017-05-25T01:26:39.163179Z 0 [ERROR] Aborting
2017-05-25T01:26:39.163179Z 0 [Note] Binlog end 2017-05-25T01:26:39.163179Z 0 [Note] mysqld: Shutdown complete Don't play cards according to the routine!!
Haha, many tutorials on the Internet are wrong, when we execute the sentence "mysqld --skip-grant-tables", mysql will find the my.ini and data folders from the bin parent directory,
Since mysql 5.7 was installed, the directory of the database data and my.ini configuration folders was changed, and it was not under the same directory as our bin folder.
In the first diagram, there is a very important parameter in the mysql service:
The correct way to change the root password is as follows:
1: Stop the mysql service 2: Open the configuration file of --defaults-file, (mine is "C:\ProgramData\MySQL\MySQL Server 5.7\my.ini"), Add a sentence to the bottom of the my.ini and save:
3: Start the MySQL service 4: Use the cmd command, cd into the bin folder of mysql, and then execute:
Just enter the password casually! ! Just enter the password casually! ! Just enter the password casually! !
We successfully entered! 5: Execute the following command:
6: Root password is successfully modified!! However, it's not over yet, let's remember to delete the sentence my.ini we just added!! Then, restart mysql!
|