关于mysql:mysql启动失败Job-for-mysqldservice-failed-because

70次阅读

共计 1454 个字符,预计需要花费 4 分钟才能阅读完成。

报错信息:

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]

正文完
 0