MySql HowTo log SQL errors
Introduction
The MySQL error log only contains errors experienced by MySQL and not queries that cause an error. And because PHP tries to make development as hard as possible, it quite often hides what errors are being returned from MySQL, either with a WSOD or with the helpful 'Unknown Error' message. Therefore, the only way to see what error is being produced is to use mysql-proxy to sit between the client and MySQL and create LUA script to display the error messages.
Procedure
Install MySQL-Proxy
- Download the latest tar file from https://downloads.mysql.com/archives/proxy/
- Unzip the file using the command
sudo tar zxf mysql-proxy-0.8.5-linux-debian6.0-{version}.tar.gz -C /usr/local
Create the lua script to log the error and run.
- Copy the script from here: http://www.chriscalender.com/capturing-erroneous-queries-with-mysql-proxy/
- Run the mysql proxy command. For example:
/usr/local/mysql-proxy-0.8.5-linux-debian6.0-x86-64bit/bin/mysql-proxy --proxy-backend-addresses=127.0.0.1:3306 --proxy-address=0.0.0.0:4045 --proxy-lua-script=/home/richard/mysql_proxy_log_errors.lua
- Change the connection string of the clinet application to use the new port (4045).
Last modified
8 years ago
Last modified on 01/27/17 09:25:02
Note:
See TracWiki
for help on using the wiki.