MySQL Log of invalid Queries

前端 未结 5 2060
一生所求
一生所求 2021-02-05 05:25

I AM NOT RUNNING THE COMMANDS FROM PHP!

I have MySQL log_error value set to /var/log/mysql/error.log

However when I connect to a database and run an SQL command,

5条回答
  •  一向
    一向 (楼主)
    2021-02-05 06:14

    Basically, there are 2 ways.

    1) setup some kind of proxy, which can log error queries. There are a lot of forks of the original mysql proxy (which was mentioned by @Mchl) - https://github.com/search?utf8=%E2%9C%93&q=MySQL+Proxy Also you can find latest version of the original mysql proxy here https://github.com/mysql/mysql-proxy

    I dont like this way, because its kind of too complicated for quick debug

    2) you can enable general log in mysql (which will log ALL queries). It will create big overhead and doesnt fit production requirements, but its fast and easy way to fix bugs in development environment.

    Just login to your mysql and execute SET GLOBAL general_log = 'ON'; SHOW GLOBAL VARIABLES LIKE 'general_log%';

    You will see logs location, like +------------------+------------------------+ | Variable_name | Value | +------------------+------------------------+ | general_log | OFF | | general_log_file | /mnt/ssd/mysql/s.log | +------------------+------------------------+

    After that execute mysqladmin flush-logs -u root -p

    When you will need to stop logs - just execute SET GLOBAL general_log = 'OFF';

提交回复
热议问题