MySQL: Is it possible to shorten error messages?
mysql, mysql-error-1064, php, syntax-error
Solution
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
Problem
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.