One of our server had Mysql failing to start on reboot with below error
tail -n 100 /var/log/mysqld.log
2022-03-08 3:53:37 0 [Note] Crash recovery finished.
2022-03-08 3:53:37 0 [Note] Server socket created on IP: ‘127.0.0.1’.
2022-03-08 3:53:37 0 [ERROR] mysqld: Can’t create/write to file ‘/var/run/mysqld/mysqld.pid’ (Errcode: 2 “No such file or directory”)
2022-03-08 3:53:37 0 [ERROR] Can’t start server: can’t create PID file: No such file or directory
2022-03-08 3:58:38 0 [Note] InnoDB: Using Linux native AIO
2022-03-08 3:58:38 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
Solution to this was
Create a new folder mkdir -p /var/run/mysqld/
Chown mysql.mysql /var/run/mysqld/
[root@ok1146s1 run]# mkdir /var/run/mysqld
[root@ok1146s1 run]# chown mysql:mysql /var/run/mysqld/
[root@ok1146s1 run]# /scripts/restartsrv_mysql
Waiting for “mysql” to start ……waiting for “mysql” to initialize ………finished.
Service Status
mariadb (/usr/sbin/mysqld) is running as mysql with PID 5809 (systemd+/proc check method).
Startup Log
Mar 08 04:08:14 ok1146s1.kvchosting.com systemd[1]: Starting MariaDB 10.3.34 database server…
Mar 08 04:08:16 ok1146s1.kvchosting.com mysqld[5809]: 2022-03-08 4:08:16 0 [Note] /usr/sbin/mysqld (mysqld 10.3.34-MariaDB) starting as process 5809 …
Mar 08 04:08:17 ok1146s1.kvchosting.com systemd[1]: Started MariaDB 10.3.34 database server.
mysql started successfully.
[root@ok116s1 run]#