1. 程式人生 > >Starting MySQL.180402 14:47:32 mysqld_safe Directory '/var/lib/mysql' for UNIX socket file don't exi

Starting MySQL.180402 14:47:32 mysqld_safe Directory '/var/lib/mysql' for UNIX socket file don't exi

本地虛擬機器(CentOS6.8)啟動MySQL(MySQL5.6.35)服務失敗

複製程式碼
[[email protected] ~]# service mysql status
 ERROR! MySQL is not running, but lock file (/var/lock/subsys/mysql) exists
[[email protected] ~]# rm -f /var/lock/subsys/mysql
[[email protected] ~]# service mysql status
 ERROR! MySQL is not running
[
[email protected]
~]# 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).
複製程式碼

前一天就折騰了mysqlsla,今天MySQL就啟動不了。參考修改CentOS6.5主機名引起MySQL5.6.35服務問題

裡面的方法沒有效果。各種糾結都沒用,最後想起啟動MySQL服務時,會優先在/etc/目錄下查詢my.cnf

複製程式碼
[[email protected] ~]# ll /etc/my.cnf
-rw-r--r--. 1 root root 251 Jan 27 05:41 /etc/my.cnf
[[email protected] ~]# 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 [[email protected] ~]# ll /etc/ |grep my -rw-r--r--. 1 root root 251 Jan 27 05:41 my.cnf [[email protected] ~]# mv /etc/my.cnf /etc/my.cnf.bak
複製程式碼

還真有/etc/my.cnf,裡面設定有socket=/var/lib/mysql/mysql.sock。我是使用原始碼在虛擬機器上安裝的MySQL,安裝目錄為/usr/local/mysql/,相關配置檔案都儲存在此目錄。並且有檢查/etc/my.cnf檔案是否存在(存在就將其重新命名/刪除)。怎麼又冒出來了?是折騰mysqlsla時出來的?

[[email protected] ~]# service mysql start
Starting MySQL........................................................... SUCCESS! 

把/etc/my.cnf重新命名後,MySQL服務順利啟動~