1.MySQL启动错误(之前正常使用,重启后报错) 版本为5.7.20
错误为:Starting MySQL… ERROR! The server quit without updating PID file
[root@KIM ~]# service mysqld status
ERROR! MySQL is not running, but lock file (/var/lock/subsys/mysql) exists
[root@KIM ~]# service mysqld start
Starting MySQL… ERROR! The server quit without updating PID file (/var/run/mysqld/mysqld.pid).
[root@KIM~]# cat /var/run/mysqld/mysqld.pid
解决过程
(1)查看日志
2022-05-12T02:24:29.871804Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
2022-05-12T02:24:29.871830Z 0 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
2022-05-12T02:24:29.871850Z 0 [Note] - '0.0.0.0' resolves to '0.0.0.0';
2022-05-12T02:24:29.872976Z 0 [Note] Server socket created on IP: '0.0.0.0'.
2022-05-12T02:24:29.874345Z 0 [ERROR] /usr/local/mysql/bin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 13 - Permission denied)
2022-05-12T02:24:29.874361Z 0 [ERROR] Can't start server: can't create PID file: Permission denied
(2)因为是无法创建 create/write to file ‘/var/run/mysqld/mysqld.pid’,所以主动创建该目录以及文件 并赋权
mkdir /var/run/mysqld
chmod -R 777 /var/run/mysqld/
touch mysqld.pid
chmod -R 777 /var/run/mysqld/mysqld.pid
(3)再次启动就成功了
[root@KIM mysqld]# touch mysqld.pid
[root@KIM mysqld]# chmod -R 777 /var/run/mysqld/mysqld.pid
[root@KIM mysqld]# ll
total 0
-rwxrwxrwx. 1 root root 0 May 12 10:51 mysqld.pid
[root@KIM mysqld]# service mysqld start