解决job for mysqld.service failed because the control process exited with error code. see “systemctl status mysqld.service” and “journalctl -kb88凯时官网登录

时间:2020-03-22
阅读:
免费资源网 - https://freexyz.cn/

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 28  2018 auto.cnf
-rw-r----- 1 mysql mysql 1073743056 nov 16 12:01 binlog.000704
-rw-r----- 1 mysql mysql  632852623 nov 21 12:12 binlog.000705
-rw-r----- 1 mysql mysql        178 nov 21 12:15 binlog.000706
-rw-r----- 1 root  root        2844 nov 21 13:01 binlog.000707
-rw-r----- 1 root  root         199 nov 21 13:01 binlog.000708
-rw-r----- 1 root  root         178 nov 21 13:01 binlog.000709
-rw-r----- 1 root  root          96 nov 21 13:01 binlog.index
-rw------- 1 mysql mysql       1680 nov 28  2018 file11
-rw-r--r-- 1 mysql mysql       1112 nov 28  2018 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

解决。

免费资源网 - https://freexyz.cn/
返回顶部
顶部
网站地图