环境
centos7.3 想要安装mysql5.7
启动mysql服务失败
service mysqld restart
Redirecting to /bin/systemctl restart mysqld.service
Job for mysqld.service failed because the control process exited with error code.
See "systemctl status mysqld.service" and "journalctl -xe" for details.
解决办法
查看mysql服务状态
systemctl status mysqld.service
结果如下
mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Tue 2019-08-06 00:00:53 CST; 4min 32s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 18915 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=1/FAILURE)
Process: 18892 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 18282 (code=exited, status=1/FAILURE)
Aug 06 00:00:52 iZuf6fx717wv2o5sdh8q9hZ systemd[1]: Starting MySQL Server...
Aug 06 00:00:52 iZuf6fx717wv2o5sdh8q9hZ mysqld_pre_systemd[18892]: 2019-08-05T16:00:52.439714Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --ex...details).
Aug 06 00:00:52 iZuf6fx717wv2o5sdh8q9hZ mysqld_pre_systemd[18892]: 2019-08-05T16:00:52.441176Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
Aug 06 00:00:52 iZuf6fx717wv2o5sdh8q9hZ mysqld_pre_systemd[18892]: 2019-08-05T16:00:52.441194Z 0 [ERROR] Aborting
Aug 06 00:00:53 iZuf6fx717wv2o5sdh8q9hZ systemd[1]: mysqld.service: control process exited, code=exited status=1
Aug 06 00:00:53 iZuf6fx717wv2o5sdh8q9hZ systemd[1]: Failed to start MySQL Server.
Aug 06 00:00:53 iZuf6fx717wv2o5sdh8q9hZ systemd[1]: Unit mysqld.service entered failed state.
Aug 06 00:00:53 iZuf6fx717wv2o5sdh8q9hZ systemd[1]: mysqld.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
罪魁祸首
- 查看数据文件,数据文件存在,被占用
cd /var/lib/mysql
2.备份 mv mysql mysql.bak
3.重启服务 service mysqld restart