Reputation: 67
Say I browse a php page, how do I know what database queries are run? I think if I can log all the queries to a .txt file that would solve my problem. I tried to log, but failed. I just want to know the queries (sql strings) sent to it.
I'm using WinXP and Apache.
Upvotes: 2
Views: 1927
Reputation: 6896
Find your mysql log files directory - mine was:
C:\Program Files\MySQL\MySQL Server 5.0\data
Look for the last updated file. Should be NAME OF YOUR COMPUTER.log - that will be your default logfile ** - Mysql is generally shipped with basic logging enabled, IIRC.
Else, as has been said, set up logging in your cnf file and restart the Mysql service.
** Make yourself a shortcut to this file on your desktop, you should be looking at it often.
When the file gets too big, delete it and restart the Mysql service and it'll start a new one with the same name.
Upvotes: 0
Reputation: 85546
One way to do it is going into your my.cnf configuration file and activate the general log. As hinted is a performance killer, so never activate it in production. For development is perfectly OK, though. On my laptop is on all the time.
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
general_log_file = /var/log/mysql/mysql.log
general_log = 1
Upvotes: 9
Reputation: 4084
just copy and paste the string in mysql_query()
into an echo just before the query.
Upvotes: -4