MySQL logging queries under OS X

I really wanted to get MySQL logging all the queries rails was producing.  After a good hour of messing around I have cracked it!

Mac OS X has a startup file which starts mysql on startup.  This needs to be modified to turn on logging support.

This can be found in /Library/StartupItems/MySQLCOM.  The file required editing is MySQLCOM.  Open it up using your favorite text editor.  The the StartService() method, and then after the start command add

” –log=/var/log/mysqld.log”

To create the log file, use the following commands

sudo cd /var/log

sudo touch mysqld.log

sudo chown mysql mysqld.log

Once that has been done, restart the server

sudo /Library/StartupItems/MySQLCOM/./MySQLCOM restart

You can then tail the log file and see all the queries in real time

tail -f mysqld.log


Bobs your uncle! Done


Technorati tags: , ,

Leave a Reply

Your email address will not be published. Required fields are marked *