【MySQL】MySQL 5.7 error和warnings無具體資訊顯示

神諭丶發表於2017-06-16
【問題描述】:


版本:MySQL 5.7.18 
安裝方式:二進位制值包解壓後直接初始化
現象:只有錯誤程式碼,無錯誤詳情,通過show errors和show warings都無法獲取message。


  1. mysql> USE ccadacdasc;
  2. ERROR 1049 (42000): Unknown error 1049
  3. mysql> SHOW ERRORS;
  4. +-------+------+----------+
  5. | Level | Code | Message  |
  6. +-------+------+----------+
  7. | Error | 1064 |          |
  8. +-------+------+----------+
  9. 1 row in set (0.00 sec)
  10. mysql> CREATE DATABASE mysql;
  11. ERROR 1007 (HY000): Unknown error 1007
  12. mysql> STOP SLAVE;
  13. Query OK, 0 rows affected, 1 warning (0.00 sec)
  14. mysql> SHOW WARNINGS;
  15. +-------+------+-----------+
  16. | Level | Code | Message   |
  17. +-------+------+-----------+
  18. | Note  | 3084 |           |
  19. +-------+------+-----------+
  20. 1 row in set (0.00 sec)


雖然不影響使用,也可以到文件手冊去查詢具體情況,但總歸不方便。

檢查錯誤日誌發現:
2017-06-16T06:40:03.292520Z 0 [ERROR] Can't find error-message file '/data/mysql57/bin/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.

發現errmsg.sys找不到,並且發現在bin目錄中查詢。


【解決方案】:

檢查配置檔案發現:
# grep basedir my57.cnf 
basedir = /data/mysql57/bin

basedir指定的位置有誤。修改一下:
basedir = /data/mysql57


重新啟動,發現無報錯。
再手工產生一些error和warning,已經可以正常產生資訊了。

  1. mysql> STOP SLAVE;
  2. Query OK, 0 rows affected, 1 warning (0.00 sec)
  3. mysql> SHOW WARNINGS;
  4. +-------+------+--------------------------------------------------------------------------+
  5. | Level | Code | Message                                                                  |
  6. +-------+------+--------------------------------------------------------------------------+
  7. | Note  | 3084 | Replication thread(s) for channel '' are already stopped.                |
  8. +-------+------+--------------------------------------------------------------------------+
  9. 1 row in set (0.00 sec)
  10. mysql> fdsfas;
  11. ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'fdsfas' at line 1
  12. mysql> use afdasfds;
  13. ERROR 1049 (42000): Unknown database 'afdasfds'

原因:該例項啟動時被指定錯誤了basedir導致無法找到errmsg.sys,所以無法顯示具體error或warning的詳情。
修正my.cnf重新啟動mysqld即可。

這個檔案在$basedir/share中存放名在此處為:
errmsg-utf8.txt 
errmsg-utf8.txt: UTF-8 Unicode Pascal program text, with very long lines
用於儲存各類error和warning的詳情。


這個問題目前只存在於MySQL 5.7等更高版本的MySQL中。

在MySQL 5.6版本中,若因為指定了錯誤的basedir,導致無法找到errmsg.sys時,在啟動時就會報錯:
2017-06-16 15:02:49 11234 [ERROR] Can't find messagefile '/data/mysql-base/mysql56/bin/share/errmsg.sys'

而在MySQL 5.7版本中,雖然在啟動時會報錯並記錄在錯誤日誌中,但mysqld仍然是可以起來的。



作者微信公眾號(持續更新)

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

相關文章