A Solution for Windows:
Is this a problem?
MySQL syntax error messages are prepended with a long string of text that is essentially useless:
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use"
In fact, it is so long that it's difficult to use in MySQL's Workbench program because the errors display on a single line:
As you can see, the actual meat of the message is somewhere to the right, unavailable to us. The only way to get the whole error is to left click the message to select it, then right-click on it and choose "Copy Response", and then paste it somewhere to see the full message. This is widely considered to be a bad user experience.
So yes, it is a problem.
How do we fix it? Well, there is a right way to do it (modify the source and rebuild, see instructions here), and there is a fast and quick way, which I only recommend for development machines, because while there probably aren't any side effects, who really knows?
Here's the fast and quick way:
This is a solution for Windows only. Something similar may work on Mac, but I have no idea.
You'll need a hex editor. A free one like HxD or an open source option like Frhed will work.
Follow these steps:
- In your MySQL installation directory, first make a backup of the file
share\english\errmsg.sys
just in case.
- In the hex editor, open the
errmsg.sys
file.
- Search for the string "
You have an error
"
- In the right-hand side of the hex editor, start at the first letter of the message, and type over the existing text. I replaced my text with a simple "Syntax error"
- Immediately after your new message, add a hex 00 character by switching back to the left-hand side of the hex editor and entering the 00 there. That ASCII NULL character tells MySQL that the message is complete. You can just ignore everything after that or replace it with spaces if you need to be that obsessive. (I was).
Here is what it should look like: (highlighted for your convenience)
In my editor, the NULL character displays on the right as a period. Don't let that confuse you.
- Save the file
- Restart the MySQL service
At this point, your syntax error messages will be much shorter. The only catch is, for this error, you cannot remove the word "near" after your message. So in our case, the message will now be "Syntax error near" etc.
Here's what it should look like if you've done everything right:
This is original work, posted here for the first time. Hope this helps!