mysql service startup exception; mysql service is lost;

background

Recently, many people have encountered mysql exception problems. They checked them one by one. But today, I suddenly encountered this problem myself. I usually follow the problem to find Du Niang. However, in order to have a faster solution, I decided to take this opportunity to sort out the solutions for mysql exceptions.

The mysql service on the local computer stops after it is started

The first problem at the beginning is to execute mysql commands through cmd. Prompt error, approximate error, I remember it is 10061 error code. Because I am familiar with this error, the first thing I do after seeing this error is to immediately check whether the mysql service is still there. Sure enough, the service was lost. Immediately, I re registered the mysql service through the following methods:

1. Enter C:\Program Files (x86)\MySQL\MySQL Server 5.7

2. Open cmd administrator mode and enter the above folder

3. Execute the following command to register the mysql service: mysqld install Mysql

4. Check whether the Mysql service is successfully registered in the service list

5. It should be successful!

At this time, click Start mysql service and an error is reported. The general content is: stop after the mysql service on the local computer is started

Don't panic at this time. Open cmd in C:\Program Files (x86)\MySQL\MySQL Server 5.7.

View the following error message through the command: mysqld --console:

C:\Program Files (x86)\MySQL\MySQL Server 5.7\bin>mysqld --console
mysqld: Can't change dir to 'C:\Program Files (x86)\MySQL\MySQL Server 5.7\data\' (Errcode: 2 - No such file or directory)
2021-01-25T08:03:36.115705Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-01-25T08:03:36.115822Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2021-01-25T08:03:36.116504Z 0 [Note] mysqld (mysqld 5.7.23) starting as process 14424 ...
2021-01-25T08:03:36.121112Z 0 [Warning] Can't create test file C:\Program Files (x86)\MySQL\MySQL Server 5.7\data\DESKTOP-4C5EAT0.lower-test
2021-01-25T08:03:36.121507Z 0 [Warning] Can't create test file C:\Program Files (x86)\MySQL\MySQL Server 5.7\data\DESKTOP-4C5EAT0.lower-test
2021-01-25T08:03:36.122259Z 0 [ERROR] failed to set datadir to C:\Program Files (x86)\MySQL\MySQL Server 5.7\data\
2021-01-25T08:03:36.122612Z 0 [ERROR] Aborting
 
2021-01-25T08:03:36.122797Z 0 [Note] Binlog end
2021-01-25T08:03:36.123029Z 0 [Note] mysqld: Shutdown complete

The error message is: the folder where the database data is stored, data, cannot be found! So I looked for it according to the mistakes given in the log. It really didn't. My God, I suddenly remembered that I put the data folder in another folder: C:\ProgramData\MySQL\MySQL Server 5.7. Sure enough, I saw what to do. Re point the data folder to C:\ProgramData\MySQL\MySQL Server 5.7. This requires my INI file, if there is no my Ini find someone to copy a file, and then configure the datadir attribute in the file:

# Path to the database root
datadir=C:/ProgramData/MySQL/MySQL Server 5.7/Data

Restart mysql service. The problem is solved.

enclosed

Start the mysql service by clicking the button in the service list. You can also start with the following command:

net start Mysql --explicit_defaults_for_timestamp

Keywords: Database MySQL

Added by tlenker09 on Sat, 18 Dec 2021 08:29:29 +0200