1

I want to log queries to just one table.

I have found these

SET GLOBAL log_output = "FILE"; which is set by default.
SET GLOBAL general_log_file = "/path/to/your/logfile.log";
SET GLOBAL general_log = 'ON';

However this logs all queries.

There are questions on SO, but they are for total logging.

How to show the last queries executed on MySQL?

Log all queries in mysql

Rohit Gupta
  • 2,116
  • 8
  • 19
  • 25

2 Answers2

0

If you want to log all activities for the given table (select/insert/update/delete) you have no choice but log everything.
If you want to log only modifications made to the table (insert/update/delete) you can enable a replication master binlog and restrict it to the desired table:

 replicate-do-table=db_name.tbl_name

Sure, you have to use mysqlbinlog utility to decode binlog.

Further reading: https://dev.mysql.com/doc/refman/8.4/en/replication-options-replica.html#option_mysqld_replicate-do-table

Kondybas
  • 4,800
  • 19
  • 16
-1

You cannot use the general log or slow log to be dedicated to a single table.

Here is a suggestion: Setup a Query Digest

It is possible to setup a Query Digest Without using the Slow Log. How ???

You can install pt-query-digest and have it examine the MySQL Processlist

You can run pt-query-digest every hour and then you can read the query digest header for every query and look for the table that you wish to profile for SELECTs, INSERTs, UPDATEs, and DELETEs.

Here are some past posts on this using pt-query-digest

I have suggested this many times over the years

RolandoMySQLDBA
  • 185,223
  • 33
  • 326
  • 536