剛接觸MySql數據庫,參考一些文章后搭建起來了也創建了數據庫,程序跑到很好,一覺醒來突然連接不上了 MySql數據庫了。
研究了好一會才找到原因。
現象:
登錄數據庫失敗
[root@VM_0_6_centos ~]# mysql -u root -p******
Warning: Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
數據庫服務重啟也失敗
[root@VM_0_6_centos ~]# /etc/init.d/mysql restart
ERROR! MySQL server PID file could not be found!
Starting MySQL.... ERROR! The server quit without updating PID file (/usr/local/mysql/data/VM_0_6_centos.pid).
查看MySql線程並殺死
[root@VM_0_6_centos ~]# ps -ef|grep mysqld
root 803 32742 0 20:45 pts/0 00:00:00 grep --color=auto mysqld
[root@VM_0_6_centos ~]# kill -9 803
-bash: kill: (803) - No such process
[root@VM_0_6_centos ~]# kill -9 32742
* SSH connection closed *
* Connection closed *
* Socket connection established *
Last failed login: Tue Nov 6 20:46:12 CST 2018 from 58.218.92.46 on ssh:notty
There were 63 failed login attempts since the last successful login.
Last login: Tue Nov 6 20:43:16 2018 from 119.29.96.147
重啟后還是同樣的問題,檢查MySql日志 /usr/local/mysql/data/VM_0_6_centos.err
2018-11-06 20:55:02 1764 [ERROR] /usr/local/mysql/bin/mysqld: unknown variable 'lower_case_file_system=1'
2018-11-06 20:55:02 1764 [ERROR] Aborting
才想起來前一晚為解決數據庫大小寫敏感問題在下面兩個文件添加了lower_case_file_system=1
/usr/local/mysql/my.cnf
/etc/my.cnf.d/mysql-cient.cnf
刪除后重啟service,問題解決!
[root@VM_0_6_centos ~]# /etc/init.d/mysql restart
ERROR! MySQL server PID file could not be found!
Starting MySQL. SUCCESS!