4

is there a way we can view the incoming query requests to mysql server. I have a scenario where my asp.net application refuses to execute a query, but the same query executes inside of a mysql query browser. I have installed the mysql dotnet connector (5.0.9) via which I can conncet to the database.

I have referred this page, but I guess this will only work within the mysql session. The mysql server is hosted on a centos machine.

Community
  • 1
  • 1
deostroll
  • 11,661
  • 21
  • 90
  • 161

3 Answers3

5

Sounds like you want the mysql query log

Edit: Try this:

  1. Edit my.cnf in /etc/mysql/my.cnf
  2. /etc/init.d/mysql restart
  3. Look in /var/log/mysql
Tom Ritter
  • 99,986
  • 30
  • 138
  • 174
  • I tried doing /etc/init.d/mysqld restart --log I was expecting it should give a log but it didn't; I don't know if I am looking in the right place. In /etc/my.cnf file the data directory is reported as /var/lib/mysql. But I can't find the log file there either. – deostroll Aug 27 '09 at 15:11
2

Followed the steps mentioned by Tom Ritter. To be more specific...

While editing /etc/m.cnf (this is where ur mysql config info sits) find a section that says mysqld. Just below that type the following:

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

Do a the rest as mentioned in Tom Ritter's post.

deostroll
  • 11,661
  • 21
  • 90
  • 161
1

On windows, you can configure a MySQL server instance to log all incoming queries by following the steps below:

  • Open your MySQL server configuration file which by default should live at the following path: "%SystemDrive%\ProgramData\MySQL\MySQL Server 5.7\my.ini" (note that 5.7 is the version number and could vary based on the version of your instance)

  • Locate the following portion of the configuration script:

    # General and Slow logging.
    log-output=FILE
    general-log=0
    general_log_file="LAPTOP-123456.log"
    slow-query-log=1
    slow_query_log_file="LAPTOP-678901-slow.log"
    long_query_time=10
    
  • Change the third line of the code snippet from

    general-log=0 
    

    to

    general-log=1
    
  • Restart your MySQL server

Henceforth, all incoming queries to your MySQL server will be written to the file at the following path: "%SystemDrive%\ProgramData\MySQL\MySQL Server 5.7\Data\LAPTOP-123456.log". Note that the file name is the same as the value of general_log_file in the configuration script

Hafiz Adewuyi
  • 360
  • 4
  • 15