How to show the last queries executed on MySQL?

后端 未结 10 966
感情败类
感情败类 2020-11-22 07:03

Is there any query/way to show the last queries executed on ALL servers?

10条回答
  •  故里飘歌
    2020-11-22 07:19

    You can enable a general query log for that sort of diagnostic. Generally you don't log all SELECT queries on a production server though, it's a performance killer.

    Edit your MySQL config, e.g. /etc/mysql/my.cnf - look for, or add, a line like this

    [mysqld]
    log = /var/log/mysql/mysql.log
    

    Restart mysql to pick up that change, now you can

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

    Hey presto, you can watch the queries as they come in.

提交回复
热议问题