解决Job for mysqld.service failed because the control process exited with error code. See “systemctl status mysqld.service” and “journalctl -xe” for details.
- 发表于
- 后端
Mysql突然无法启动了,报错:
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
根据提示信息查看
systemctl status mysqld.service
‚ó mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2019-11-21 13:08:39 CST; 16s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 2592 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS (code=exited, status=1/FAILURE)
Process: 2560 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 2592 (code=exited, status=1/FAILURE)
Status: "Server startup in progress"
Error: 13 (Permission denied)
Nov 21 13:08:38 VM_0_16_centos systemd[1]: Starting MySQL Server...
Nov 21 13:08:39 VM_0_16_centos systemd[1]: mysqld.service: main process exited, code=exited, status=1/FAILURE
Nov 21 13:08:39 VM_0_16_centos systemd[1]: Failed to start MySQL Server.
Nov 21 13:08:39 VM_0_16_centos systemd[1]: Unit mysqld.service entered failed state.
Nov 21 13:08:39 VM_0_16_centos systemd[1]: mysqld.service failed.
这里我看到了关键信息Error: 13 (Permission denied)
,无权限?继续查看一下mysqld日志,因为不记得日志路径,所以确定一下:
$ find / -name mysqld.log
/var/log/mysqld.log
查看日志
cat /var/log/mysqld.log
mysqld: File './binlog.index' not found (OS errno 13 - Permission denied)
2019-11-21T05:08:32.749994Z 0 [Warning] [MY-011068] [Server] The syntax 'expire-logs-days' is deprecated and will be removed in a future release. Please use binlog_expire_logs_seconds instead.
2019-11-21T05:08:32.751186Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.17) starting as process 2528
2019-11-21T05:08:32.753249Z 0 [ERROR] [MY-010119] [Server] Aborting
2019-11-21T05:08:32.753432Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.17)MySQL Community Server - GPL.
在这里,我得到了更为具体的信息,mysqld: File './binlog.index' not found (OS errno 13 - Permission denied)
,好吧,先追过去看一下这个binlog
。那么它的路径在哪呢?可以在etc/my.cnf
配置文件中的datadir=
中得到:
[root@VES mysql]# ls -l
total 1852876
-rw-r----- 1 mysql mysql 56 Nov 282018 auto.cnf
-rw-r----- 1 mysql mysql 1073743056 Nov 16 12:01 binlog.000704
-rw-r----- 1 mysql mysql632852623 Nov 21 12:12 binlog.000705
-rw-r----- 1 mysql mysql178 Nov 21 12:15 binlog.000706
-rw-r----- 1 rootroot2844 Nov 21 13:01 binlog.000707
-rw-r----- 1 rootroot 199 Nov 21 13:01 binlog.000708
-rw-r----- 1 rootroot 178 Nov 21 13:01 binlog.000709
-rw-r----- 1 rootroot96 Nov 21 13:01 binlog.index
-rw------- 1 mysql mysql 1680 Nov 282018 file11
-rw-r--r-- 1 mysql mysql 1112 Nov 282018 came
结果很明显了,用户权限不一样,我们的mysqld用户组是mysql那么重新授权一下:
$ chgrp -R mysql /usr/local/mysql/data && chown -R mysql /usr/local/mysql/data
这时候再重启
[root@VES 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.
所有媒体,可在保留署名、
原文连接
的情况下转载,若非则不得使用我方内容。