ITPub博客

首页 > 数据库 > MySQL > 【MySQL】MySQL 5.7 error和warnings无具体信息显示

【MySQL】MySQL 5.7 error和warnings无具体信息显示

原创 MySQL 作者:神谕丶 时间:2017-06-16 15:24:16 0 删除 编辑
【问题描述】:


版本: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博客 ” ,链接:https://blog.itpub.net/29773961/viewspace-2140844/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
微信公众号:神谕的暗影长廊

注册时间:2014-07-28

  • 博文量
    161
  • 访问量
    1194985