2

Error message:

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

I started mysql today and found that the error was reported as above, and the troubleshooting was carried out according to the following steps

1, Check the log file /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 Create a new directory /var/run/mysqld

mkdir -p /var/run/mysqld/

3 Execute the mysql start command service mysqld restart , found that it still fails, check the log /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

The error says that there is no permission.

4 Grant mysql permissions

chown mysql.mysql /var/run/mysqld/

5 Continue to restart service mysqld restart and found that it has started

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

WX20210922-091703.png


雾岛听风
12.1k 声望8.7k 粉丝

丰富自己,胜过取悦别人。