Home>Article>Database> Let you understand the reasons and solutions for MySQL startup failure

Let you understand the reasons and solutions for MySQL startup failure

WBOY
WBOY forward
2022-06-06 19:27:42 5340browse

This article brings you relevant knowledge aboutmysql, which mainly introduces related issues about mysql startup failure, including the reasons for startup failure and solutions, etc., which may be due to lack of My.ini file, lack of data files, port occupation and other issues, let's take a look at them together. I hope it will be helpful to everyone.

Let you understand the reasons and solutions for MySQL startup failure

Recommended learning:mysql video tutorial

My computer here is win10 and mysql is version 8.0.

Generally, when installing MySQL through a compressed installation package, MySQL may fail to start, as shown below:Let you understand the reasons and solutions for MySQL startup failure
Based on various information on the Internet and your own actual operations, summarize For the following three reasons:

1. Lack of my.ini file

Create the my.ini file through Notepad. You can also search for other my.ini files on your computer. After copying it, modify it (make sure it is in the format of the configuration file).

After creating the my.ini file, save it to the sever directory, as shown below:

Let you understand the reasons and solutions for MySQL startup failure

2. Lack of data file

When there is a lack of data files, be careful not to create data files manually! ! ! Manually creating the data file will still fail to start.
Operation method:
(1) Run the command control character (cmd) as administrator

Attention! ! ! If you do not run as an administrator at this time, errors may occur.

(2) Enter

mysqld --initialize --user=mysql --console

in cmd and
Let you understand the reasons and solutions for MySQL startup failure
will appear. Remember the temporary password at this time, you will use it later.

Notice! ! !
If the command line is mysqld --initialize-insecure without adding –console, when logging in to mysql, just click enter to enter. The password at this time is an empty password, but a password will be generated later, which we cannot see. Yes, I won’t be able to log in to mysql next time. (Wrong password)

(3) Run mysql

Let you understand the reasons and solutions for MySQL startup failure

Let you understand the reasons and solutions for MySQL startup failure
(4) Change the password and enter ALTER USER 'root'@' localhost' IDENTIFIED WITH mysql_native_password BY 'new password';

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

Let you understand the reasons and solutions for MySQL startup failure

3. Port occupation (MySQL's default port is 3306)

You can view it here .err file under data to check whether there is any port occupation.

Let you understand the reasons and solutions for MySQL startup failure
If the port is occupied, you can check which process occupies port 3306 by entering the following command on the command line.

netstat -ano

Let you understand the reasons and solutions for MySQL startup failure
Find the PID occupying port 3306, as shown below:
Let you understand the reasons and solutions for MySQL startup failure
Go to Task Manager to close the process corresponding to the corresponding PID.
Let you understand the reasons and solutions for MySQL startup failure
The problem is successfully solved at this time! ! !

During the process of running mysql, other errors may also occur. The corresponding reasons can be obtained by checking the .err file in the data.

Recommended learning:mysql video tutorial

The above is the detailed content of Let you understand the reasons and solutions for MySQL startup failure. 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