April 3, 2009

Reverse Engineering MySQL Queries in web apps

Kevin Hallmark @ 10:26 am —

So here I am, sitting at work. I’ve been tasked with reverse-engineering the login system for this website. Ugh. The code is spaghetti. Queries are a mish-mash. How do I figure this out?

What I discovered is that you can log literally every single mySQL query made to the server. This is really useful if you need to figure out crazy things like what queries run when new user is inserted.

Add the following line to your my.cnf file:

log = /var/log/mysql/mysql.log

This gets rid of the hassle involved with finding and tracing mysql queries directly.