Problem description:
When trying to install MYSQL under win7, the following error occurred:
Solution Method:
1. Add environment variable PATH (for example: C:\Program Files\mysql-5.7.13-winx64\bin);
2 , enter the MYSQL installation directory, create a new default configuration file my.ini;
Write the following content in the my.ini configuration file:
(The specific content can be Modify according to your own situation)
[mysql] # 设置mysql客户端默认字符集 default-character-set=utf8 [mysqld] #设置3306端口 port = 3306 # 设置mysql的安装目录 basedir=C:\Program Files\mysql-5.7.13-winx64 # 设置mysql数据库的数据的存放目录 datadir=C:\Program Files\mysql-5.7.13-winx64\data # 允许最大连接数 max_connections=200 # 服务端使用的字符集默认为8比特编码的latin1字符集 character-set-server=utf8 # 创建新表时将使用的默认存储引擎 default-storage-engine=INNODB
Save after completion. At this time, the my.ini file will replace the default my-default.ini file.
After that, we need to manually create a new data folder in the MYSQL installation directory.
3. Uninstall, reinstall, initialize MYSQL, and finally start the MYSQL service;
Run cmd as an administrator and enter the following commands in sequence:
C:Windows\system32>mysqld --remove //删除mysql服务 C:Windows\system32>mysqld --install //安装mysql服务 C:Windows\system32>mysqld --initialize //一定要初始化 C:Windows\system32>net start mysql
After the initialization command is executed, the following files are generated in the empty data directory:
Finally start the MYSQL service. If the following is displayed, it indicates that it has been started successfully.
Recommended tutorial: mysql tutorial
The above is the detailed content of How to solve the problem that mysql service cannot be started. For more information, please follow other related articles on the PHP Chinese website!