This is the 10th day of my participation in the August Gwen Challenge. For details, see: [August Gwen Challenge](juejin.cn/post/698796… “Juejin. Cn/post / 698796…”

MySQL service startup failure cause and solution

Here I am running Windows 10 and mysql 8.0.

In general, MySQL may fail to start when installed using a compressed installation package, as shown in the following figure:

Comprehensive online information, plus their own practical operation, summed up as the following three reasons:

1. The my.ini file is missing

Create the my.ini file using notepad, or search for other my.ini files on your computer, copy them, and modify them (make sure they are in the configuration file format).

To create the my.ini file, refer to this blog post:Blog.csdn.net/shinny195/a…Once you have created the my.ini file, save it to the sever directory as shown below:

2. The data file is missing

In the absence of data files, be careful not to manually create data files!! Manually creating a data file still fails to start. Operation mode: (1) Run the command control character (CMD) as administrator. If you do not run as an administrator, an error may occur. (2) Enter CMD

mysqld --initialize --user=mysql --console
Copy the code

It will appearRemember the temporary password at this time, it will be used later.

Attention!! If the command line type is mysqld –initialize-insecure, and there is no –console, when logging in to mysql, you can enter directly by pressing Enter. At this time, the password is empty, but after that, a password will be generated, which we can’t see, and the next time we can’t log in to mysql. (Password error)

(3) Run mysql

(4) Change the password BY entering ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘new password ‘;

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';

Copy the code

3. Port usage (MySQL default port 3306)

You can view the. Err file under data to check whether the port is occupied.If port 3306 is occupied, run the following command on the CLI to check which process occupies port 3306.

netstat -ano
Copy the code

Find the PID occupying port 3306 as shown below:

Go to task Manager to close the process corresponding to the corresponding PID.Problem solved successfully at this time!!

When running mysql, other errors may occur. You can check the. Err file in data to find the corresponding causes.