Question

I am on WAMP configuration. Is there a way within WAMP or a package which will allow me to see SQL queries fired from PHP to MySQL server.

I am familiar with overriding DB adapters in JAVA to see the fired SQL requests. Is there something similar in PHP

OR is there a way to view the fired SQL from mysql functions itself?

Was it helpful?

Solution

Click the WAMP tray icon, and click 'my.ini' in the MySQL menu.

Then, add the following in the [mysqld] section:

general-log=1
general-log-file = "C:\wamp\logs\mysql_general.log"

Finally, restart all services and your queries should be logged. This enables MySQL's General Query Log.

OTHER TIPS

There are few things you can do.

First if you are using function wrappers (for example query() as a wrapper for mysqli_query()) then you can echo the query from inside it (or save it to log file).

Second, you could enable General Query Log in MySQL (not recommended on live servers, since it can take a lot of space very fast!). There you may find everything that mysqld has done. More at http://dev.mysql.com/doc/refman/5.1/en/query-log.html

Third, you could install mysql proxy, which would run between your scripts and mysql, and it could output everything sent to your database. More at http://dev.mysql.com/downloads/mysql-proxy/

It all depends on what you prefer, and what is suitable for your situation.

Let me know what you think.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top