Home >Database >Mysql Tutorial >Mysql failed to start: What should I do if the mysql service cannot be started?

Mysql failed to start: What should I do if the mysql service cannot be started?

醉折花枝作酒筹
醉折花枝作酒筹forward
2021-07-01 09:12:078101browse

After MySQL server8.0 is installed, the startup fails, and the prompt message is as follows: the mysql service cannot be started, and the service does not report any errors. What should we do at this time? Below, the editor will take you through the solution. Friends in need can refer to it.

Mysql failed to start: What should I do if the mysql service cannot be started?

After installation of My SQL server8.0, the startup failed, and the prompt message is as follows:

Try the following steps, and finally Solve the problem:

1 Check the host file (C:\Windows\System32\drivers\etc\hosts) to see if the local domain name has been modified. If the address corresponding to localhost has been modified, it may cause the connection to the mysql server fail.

Solution: Comment out the address mapped by localhost

2 If there is no configuration file in the mysql installation path (C:\Program Files\MySQL\MySQL Server 8.0), manually Create one, the file name is: my.ini, add the following content:

Note: Do not create the data folder manually after the datadir attribute. I tried to create it manually. There will be problems. If you created it yourself, you can delete it and then perform the subsequent operations.

3 In mysql5.7 and above, there is no data directory by default, that is, there is no initialization service. You need to initialize mysql before you can start the service. Otherwise, "the service did not report any errors" will be reported and the startup will fail.

Solution:

a Enter the bin directory of mysql;

b Execute mysqld --initialize-insecure. If executed for the first time, it will take longer and the execution will end. There is no output information. If you check the directory at the same level as bin, there will be an additional data folder with a bunch of files in it.

4 Execute the net start mysql command again to start the service and find that the startup is successful!

Related learning recommendations: mysql tutorial(video)

The above is the detailed content of Mysql failed to start: What should I do if the mysql service cannot be started?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete