Home  >  Article  >  Database  >  What should I do if mysql cannot successfully start the service?

What should I do if mysql cannot successfully start the service?

coldplay.xixi
coldplay.xixiOriginal
2020-11-16 10:17:0752560browse

The solution to the problem that mysql cannot successfully start the service: first comment out the address mapped by localhost; then enter the bin directory of mysql to initialize mysql; finally, execute the net start mysql command again to start the service.

What should I do if mysql cannot successfully start the service?

The solution to the problem that mysql cannot successfully start the service:

View the host file (C:\Windows\System32\ drivers\etc\hosts), whether 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 to fail.

Solution:

1. Comment out the address mapped by localhost

2. If it is in the installation path of mysql (C:\Program Files\MySQL\MySQL Server 8.0 ), create one manually. The file name is: my.ini. Add the following content:

What should I do if mysql cannot successfully start the service?

Note: The data folder after the datadir attribute must be Do not create it manually. If you try to create it manually, there will be problems. If you create it yourself, you can delete it and perform the following operations.

3. In mysql5.7 or 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:

  • Enter the bin directory of mysql;

  • Execute mysqld --initialize-insecure, the first time If executed, it will take a longer time, and no information will be output after the execution. 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!

More related free learning recommendations: mysql tutorial(video)

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn