- 今天重啟一台內網服務器,發現mysql無法正常重啟,執行systemctl start mysql,報錯如下
Starting LSB: start and stop MySQL...
Dec 11 14:24:42 localhost.localdomain mysql[32329]: my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
Dec 11 14:24:42 localhost.localdomain mysql[32329]: Starting MySQL.my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
Dec 11 14:24:42 localhost.localdomain mysql[32329]: my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
Dec 11 14:24:42 localhost.localdomain mysql[32329]: Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
Dec 11 14:24:43 localhost.localdomain mysql[32329]: ERROR! The server quit without updating PID file (/usr/local/mysql/data/localhost.localdomain.pid).
Dec 11 14:24:43 localhost.localdomain systemd[1]: mysql.service: control process exited, code=exited status=1
-
剛開始關注點放在了 ERROR! The server quit without updating PID file (/usr/local/mysql/data/localhost.localdomain.pid). 這里,發現mysql下沒有data這個文件夾,以為數據庫文件丟失了呢,頭疼。
-
后來將關注點放到 my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
- 查看my.cnf的權限,
- ls -l /etc/my.cnf
- -rwxrwxrwx 1 root root 1404 Oct 16 19:31 /etc/my.cnf , 發現是777權限
- chmod 644 /etc/my.cnf , 設置為644權限
- systemctl start mysql , 一切OK
-
另外,發現無法遠程連接,之前設置過IP,用戶訪問權限,但還是重新設置了一遍,並開放端口3306,才可以遠程連接(由於設置權限和開放端口沒有分開執行,所以並未確定是端口還是權限造成的)。
GRANT ALL PRIVILEGES ON *.* TO 'username '@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;
iptables -I INPUT -p tcp --dport 3306-j ACCEPT
遠程連接成功