Solve the problem that MySQL service is starting. MySQL service cannot be started

Solve the problem that mysql cannot start

In the process of learning web system development, you need to read mysql locally on the windows system. If you encounter the problem that mysql cannot start normally, I will make some summary.

The problem shows:

Enter net start mysql but mysql cannot start normally
**

Solution:

**
1. Manual start
Search for the service application function in the Windows search bar, open the service, right-click and select Run as administrator, find MySQL in the service, and click start manually
service

2. Initialize the data directory
mysqld --initialize (random password)
mysqld --initialize-insecure (no password)

The data folder in the mysql directory must not be created manually by yourself, if any, delete it first, and then perform the following operations.
To start, configure my.ini first (remember to modify the installation directory and data directory inside):

[client]

port=3306

default-character-set=utf8

[mysqld]

# 设置为自己的MYSQL的安装目录

basedir=D:\02software\mysql-5.7.29-winx64

# 设置为自己的MYSQL的数据目录

datadir=D:\02software\mysql-5.7.29-winx64\data

port=3306

character_set_server=utf8

sql_mode=NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER

#开启查询缓存

explicit_defaults_for_timestamp=true

skip-grant-tables

After mysqld --initialize-insecure initialize the data to reset the directory, run net start mysql again
3. It is possible that port 3306 is occupied
mysqld --console can view the error message
netstat -ano to see if the port is occupied
#netstat -aon|findstr
If "3306" is occupied, check the PID corresponding to the port, terminate the process corresponding to the PID in the service, and enter net start mysql again to try
4. The local host points to the problem
C:\Windows\System32\drivers\ etc\hosts
check whether the local host points to other domain names, such as whether 127.0.0.1 points to localhost
5. User settings
can solve the problem that the service cannot be started by modifying the temporary password through user settings, enter the path on the CMD and enter the bin directory; Execute mysql -uroot, modify the password here, and then use the password to log in to the mysql environment.

Guess you like

Origin blog.csdn.net/weixin_44361102/article/details/113060142