This article brings you relevant knowledge about mysql, 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.
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:
Based on various information on the Internet and your own actual operations, summarize For the following three reasons:
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:
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
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
(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';
You can view it here .err file under data to check whether there is any port occupation.
If the port is occupied, you can check which process occupies port 3306 by entering the following command on the command line.
netstat -ano
Find the PID occupying port 3306, as shown below:
Go to Task Manager to close the process corresponding to the corresponding PID.
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!