Starting MySQL ** mysqld_safe Directory '/var/lib/mysql' for UNIX socket file don't exists

时间:2022-02-19 00:31:44

本地虚拟机(CentOS6.8)启动MySQL(MySQL5.6.35)服务失败

Starting MySQL ** mysqld_safe Directory '/var/lib/mysql' for UNIX socket file don't exists
[root@VMUest ~]# service mysql status
 ERROR! MySQL is not running, but lock file (/var/lock/subsys/mysql) exists
[root@VMUest ~]# rm -f /var/lock/subsys/mysql
[root@VMUest ~]# service mysql status
 ERROR! MySQL is not running
[root@VMUest ~]# service mysql start
Starting MySQL.170331 10:18:30 mysqld_safe Directory '/var/lib/mysql' for UNIX socket file don't exists.
 ERROR! The server quit without updating PID file (/usr/local/mysql/data/VMUest.pid).
Starting MySQL ** mysqld_safe Directory '/var/lib/mysql' for UNIX socket file don't exists

前一天就折腾了mysqlsla,今天MySQL就启动不了。参考修改CentOS6.5主机名引起MySQL5.6.35服务问题里面的方法没有效果。各种纠结都没用,最后想起启动MySQL服务时,会优先在/etc/目录下查找my.cnf

Starting MySQL ** mysqld_safe Directory '/var/lib/mysql' for UNIX socket file don't exists
[root@VMUest ~]# ll /etc/my.cnf
-rw-r--r--. 1 root root 251 Jan 27 05:41 /etc/my.cnf
[root@VMUest ~]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql




# Disabling symbolic- links is recommended to prevent assorted security risks symbolic-links= 0 [mysqld_safe] log-error=/var/log/ mysqld.log pid- file=/var/run/mysqld/ mysqld.pid [root@VMUest ~]# ll /etc/ | grep my -rw-r--r--. 1 root root 251 Jan 27 05: 41 my.cnf [root@VMUest ~]# mv /etc/my.cnf /etc/my.cnf.bak
Starting MySQL ** mysqld_safe Directory '/var/lib/mysql' for UNIX socket file don't exists

还真有/etc/my.cnf,里面设置有socket=/var/lib/mysql/mysql.sock。我是使用源码在虚拟机上安装的MySQL,安装目录为/usr/local/mysql/,相关配置文件都保存在此目录。并且有检查/etc/my.cnf文件是否存在(存在就将其重命名/删除)。怎么又冒出来了?是折腾mysqlsla时出来的?

[root@VMUest ~]# service mysql start
Starting MySQL........................................................... SUCCESS! 

把/etc/my.cnf重命名后,MySQL服务顺利启动~