How to monitor sql query in mysql?


mysql logoMonitor what sql query is running in mysql is very import for performance analysis. By monitor sql query, you are be able to know what is running at the backend. if your framework logs all sql queries then you can monitor from there, if not, you might need to turn on mysql log to monitor all the sql query being executed.

To monitor sql query in MySQL, simply follow the steps below:-

Advertisements

  • Open your MySQL configuration file, normally it located at /etc/mysql/my.cnf
  • Look for a this line
  • remove the # and save the file
  • Now, restart your mysql server to take immediate effect
  • To monitor sql query real time, you may use this command

    Once you run this command, it will show the last executed message being added to the log file, so you will be able to see all the sql query that is being executed.

*** Note: After you turn on the logging, it will slow down the mysql performance. Try to do this in development server and NOT IN PRODUCTION server ***

Related posts:






Share this with your friends:-

One Response to “How to monitor sql query in mysql?”

  1. Glenn McKay says:

    MONyog- https://www.webyog.com/product/monyog is a very good monitoring tool for MySQL server. I am using it’s Real-Time and Query Analyzer feature to find out problem SQL and later optimize them to improve performance.

Leave a Reply