This article is a mirror article of machine translation, please click here to jump to the original article.

View: 24914|Reply: 3

[Source] MySQL Server 5.7 Reset the root password

[Copy link]
Posted on 5/25/2017 9:51:07 AM | | | |
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!

Score

Number of participants1MB+1 contribute+1 Collapse reason
tututu + 1 + 1 Very powerful!

See all ratings





Previous:CSS PC and mobile phone width adaptation issues
Next:C# uses ICSharpCode.SharpZipLib.dll to compress and decompress files/folders
Posted on 11/8/2018 4:50:55 PM |
Great, but when I enter the password casually, it prompts:
C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql.exe -uroot -h 127.0.0.1 -p
Enter password: *****
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (10061)
Posted on 11/22/2018 7:38:30 PM |
Thank you, boss, I finally solved it and realized the remote connection to the MySQL database, which took a week to hack. The moment the telnet was turned on today, it seemed to cure the old constipation that had been bothering me for many years~
Thanks again!!
Posted on 12/27/2018 10:20:46 PM |
Big brother, big brother, finally solved the !!!!!! Thank you so much!!!!!!!!!
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com