MySQL啟動失敗

ittangzeng發表於2018-04-26
一、錯誤日誌:
[mysql@host-172-24-115-217 ~]$ service mysql restart
Shutting down MySQL.. SUCCESS! 
Starting MySQL..180426 13:36:03 mysqld_safe Logging to '/usr/local/mysql/data/alert.log'.
180426 13:36:03 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. ERROR! 


二、分析日誌
(1)檢視日誌
usr/local/mysql/data/alert.log
發現:Version: '5.5.59-MariaDB'  socket: '/usr/local/mysql/data/mysql.sock'  port: 3306  MariaDB Server
表示mysqld 啟動完畢。

(2)檢視程式
[mysql@host-172-24-115-217 fd]$ ps -ef | grep mysqld
mysql    20633     1  0 13:36 pts/5    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/mysqlProcess.pid
mysql    21736 20633  0 13:36 pts/5    00:00:02 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/usr/local/mysql/data/alert.log --pid-file=/usr/local/mysql/data/mysqlProcess.pid --socket=/usr/local/mysql/data/mysql.sock --port=3306
mysql    22436  7333  0 13:40 pts/3    00:00:00 grep mysqld

分析:
從日誌和程式資訊可以看出此mysqld服務正常。那為什麼出現啟動失敗的現象。

三、挖掘原因
既然mysqld服務程式正常,那從其它機器是否可以登入。經過測試
[mysql@host-172-24-115-218 ~]$ mysql -h172.24.115.217 -uroot -pmysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 1
Server version: 5.5.59-MariaDB MariaDB Server


Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


MariaDB [(none)]> 

經過驗證,可以登入。

四:結論
從此可以推斷
mysql伺服器的client配置錯誤,導致mysql程式讀取配置導致異常

檢查/etc/my.cnf 發現如下:
[client]
#socket = /usr/local/mysql/data/mysql.sock
default-character-set = gbk 
port = 3306

缺少紅色部分,註釋後,再次重啟一切正常。


希望改進:
希望mysql的啟動過程相關的shell指令碼也能新增相應的日誌,協助分析問題。

That is all.
Good Luck!










來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29497382/viewspace-2153389/,如需轉載,請註明出處,否則將追究法律責任。

相關文章