During program debugging, one way is to start from the first line, which is very hard (for example, the program source files are too many or compiled or encrypted ). The other method is to check from the back. The last write is the DB, so we start to push forward from the DB, so we need to grasp what SQL syntax the program executes.
The tracing method we used previously was to use tcpdump or wireshark to listen to the 3306 port. This is too bitter and I will not talk about it more ~
MySQL can be used in several ways. Add/etc/mysql/my. cnf (debian) to one of your favorite methods and restart mysql:
First: query the SQL Syntax of Slow query:
Log_slow_queries =/var/log/mysql/mysql-slow.log.
Long_query_time = 2 (the SQL syntax is recorded for more than 2 seconds. It is also a method to set a short value to record the exception .)
Type 2: Set binlog for MySQL Replication:
Log_bin =/var/log/mysql/mysql-bin.log (this file should be viewed using mysqlbinlog)
Mysql records all INSERT/UPDATE/DELETE syntaxes here (but the syntax may be different from what you think). This is the log file to be written to SLAVE.
Method 3: We recommend that you record all the commands executed by MySQL:
Log =/tmp/mysql. log
After restart mysql, You can see tail-f/tmp/mysql. log! :)
Supplement: the earliest method is mysqldump, and then mysqldump and diff after execution, but this method is abandoned after DB> 1G.