When developing an application that uses MySQL, it can be useful to watch in real time what requests are being made.

How to see all incoming MySQL queries?

3 Answers 3


As root, edit /etc/mysql/my.cnf and add this paragraph at the bottom:


Still as root, run these commands:

service mysql stop
service mysql start

Then observe the log:

tail -f /var/log/mysql/query.log

Please beware that this setting makes MySQL about 15% slower, so remove or comment the paragraph (then restart) when you don't need it anymore.

  • service mysql stop asking password, I have solution without password. try : sudo /etc/init.d/mysql stop then sudo /etc/init.d/mysql start . This will bypass password prompt. Dec 15, 2021 at 7:34

Although Nicolas Raoul's answer is right on point, note that as of mysql-server-5.7, the /etc/mysql/my.cnf file is constructed from the config files in both /etc/mysql/conf.d and /etc/mysql/mysqld.conf.d.

So for the solution to work, the file: /etc/mysql/mysqld.conf.d/mysqld.cnf has to be modified. So, the lines:

#general_log_file        = /var/log/mysql/mysql.log
#general_log             = 1

Have to be uncommented, the file saved, and the service restarted with sudo service mysql restart.

Otherwise, you might get errors.


Run this command using linux shell script

mysqladmin -uroot -p'mysql_password ' -i 2 processlist

Will generate processlist and automatically refresh on every minutes

  • 2
    Would you mind posting a sample output, to see what it looks like? Thanks :-) Aug 8, 2019 at 10:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.