Wednesday, June 2, 2010

Overwrite MySQL Error Messages

Well, in the current project where I am responsible to migrate SQL Server 2005 to MySQL 5.x database, I've found an interesting use case. The application development team expects the custom alert messages to be sent from the MySQL database(This is handled by using the raiseerror keyword in SQL Server 2005). In order to approach this problem, I've investigated couple of ways out of which one turned out to be as a solution: customizing the default MySQL error messages.

P.S: This is currently working ONLY on WINDOWS platform

Procedure:

  1. Explore through /share/errmsg.txt
  2. Edit the required error text. For example: ER_PARSE_ERROR & ER_SYNTAX_ERROR (in my scneario)
  3. In the command prompt,navigate through /bin
  4. Execute the following command: comp-err --charset=../share/charsets --in_file=../share/errmsg.txt --out_dir=../share
  5. Restart MySQL service.
Good Luck!!

No comments: