MySQL:是否可以缩短错误消息? [英] MySQL: Is it possible to shorten error messages?
问题描述
我听到很多人抱怨这个,这是有道理的.许多 MySQL 错误消息长得可笑:
您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以获取在附近使用的正确语法...
这在只显示字符串前半部分的环境中尤其令人讨厌.所以问题是:是否有可能获得该字符串的较短版本?类似于:Syntax error near...
- 这确实是该消息的重要部分.
注意:这里提供的步骤仅适用于 Linux,您可能正在使用其他操作系统,然后使用相应的编辑器和命令>
MySQL 将错误消息文件存储在 /usr/share/mysql/english/errmsg.sys
,其中 english
是您要使用的语言.
注意:您需要拥有超级用户权限
步骤 1. 备份现有的 errmsg.sys(以便在出现问题时可以恢复
$sudo cp/usr/share/mysql/english/errmsg.sys ~/errmsg.sys.bkp
步骤 2. 在 vi
编辑器中打开 /usr/share/mysql/english/errmsg.sys
.
$sudo vi/usr/share/mysql/english/errmsg.sys
第 3 步.在 errmsg.sys 中搜索You have an"
在vi编辑器中搜索试试这种方式-->/你有一个[按回车]
它会让你看到字符串你有一个错误......",如屏幕截图所示
第 4 步.根据您的需要编辑该错误消息.我删除了字符串 你的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册
并保留 要使用的正确语法
检查下面的屏幕截图.
第 5 步.保存并退出.
在vi编辑器中保存退出-->:X![按回车]在这里!添加以覆盖只读文件
步骤 6. 重启 mysql
服务.
$sudo mysql 重启
步骤 7. 检查错误消息(我正在 phpMyAdmin 中检查)
在此答案中,我更新了错误消息 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以获取在附近使用的正确语法...
同样,您也可以更新其他标准错误消息.
希望有帮助!:D
I have heard a lot of people complain about this, and justifiably so. Many MySQL error messages are ridiculously long:
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...
This gets especially annoying in environments that only show you the first half of that string. So the question is: Is it possible to get a shorter version of that string? Something like: Syntax error near...
- which is really the juicy part of that message.
Note:The steps provided here are only for Linux, you might be using some other OS then use respective editor and commands
MySQL stores error message file at /usr/share/mysql/english/errmsg.sys
where english
is the language you want to use.
Note:You need to have super user privileges
Step 1. Take backup of existing errmsg.sys (so that you can revert if some problem occured
$sudo cp /usr/share/mysql/english/errmsg.sys ~/errmsg.sys.bkp
Step 2. Open /usr/share/mysql/english/errmsg.sys
in vi
editor.
$sudo vi /usr/share/mysql/english/errmsg.sys
Step 3. Search for "You have an" in errmsg.sys
in vi editor for searching try this way--> /You have an [press enter]
It will get you to the string "You have an error...." as show in screen-shot
Step 4. Edit that error message as per your need. I've deleted string You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the
and kept just right syntax to use
Check below screen-shot.
Step 5. Save and Exit.
in vi editor to save and exit--> :x! [press enter] here ! is added to override read-only file
Step 6. Restart mysql
service.
$sudo mysql restart
step 7. check error message (I'm checking in phpMyAdmin)
In this answer I've updated error message 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...
similarly you can update other standard error message as well.
Hope it helped ! :D
这篇关于MySQL:是否可以缩短错误消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!