mysql启动失败:Job for mysqld.service failed because..

Posted JenK

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql启动失败:Job for mysqld.service failed because..相关的知识,希望对你有一定的参考价值。

报错信息:

Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

今天启动mysql发现报错如上提示,根据如下步骤进行了排查修复

1, 检查日志文件 /var/log/mysqld.log

tail -f /var/log/mysqld.log
2021-06-29T06:00:14.989419Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2021-06-29T06:00:14.992452Z 0 [Note] Plugin \'FEDERATED\' is disabled.
2021-06-29T06:00:15.000437Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2021-06-29T06:00:15.000859Z 0 [Warning] CA certificate ca.pem is self signed.
2021-06-29T06:00:15.002287Z 0 [Note] Server hostname (bind-address): \'*\'; port: 3306
2021-06-29T06:00:15.002345Z 0 [Note] IPv6 is available.
2021-06-29T06:00:15.002377Z 0 [Note]   - \'::\' resolves to \'::\';
2021-06-29T06:00:15.002393Z 0 [Note] Server socket created on IP: \'::\'.
2021-06-29T06:00:15.039471Z 0 [ERROR] /usr/sbin/mysqld: Can\'t create/write to file \'/var/run/mysqld/mysqld.pid\' (Errcode: 2 - No such file or directory)
2021-06-29T06:00:15.039485Z 0 [ERROR] Can\'t start server: can\'t create PID file: No such file or directory

2 新建 /var/run/mysqld目录

mkdir -p /var/run/mysqld/

3 执行mysql启动命令service mysqld restart, 发现依然失败, 再次检查日志 /var/log/mysqld.log

[ERROR] /usr/sbin/mysqld: Can\'t create/write to file \'/var/run/mysqld/mysqld.pid\' (Errcode: 13 - Permission denied)
[ERROR] Can\'t start server: can\'t create PID file: Permission denied

报错说是没有权限.

4 赋予mysql权限

chown mysql.mysql /var/run/mysqld/

5 继续重启service mysqld restart,发现已经启动

service mysqld restart
Restarting mysqld (via systemctl):                         [  OK  ]

以上是关于mysql启动失败:Job for mysqld.service failed because..的主要内容,如果未能解决你的问题,请参考以下文章

centos7启动MySQL报 Job for mysqld.service failed because the control process exited with error code. Se

MySQL 启动报错:Job for mysqld.service failed because the control process exited with error code.

MySQL 启动报错:Job for mysqld.service failed because the control process exited with error code.

MySQL 启动报错:Job for mysqld.service failed because the control process exited with error code.

在Linux上重启MySQL服务报错“Job for mysqld.service failed because the control process exited with error code“

关于mysql启动不了的心得,使用systemctl restart mysqld失败