Where to View TiDB Database Operation Logs

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: tidb数据库操作日志上哪看

| username: TiDBer_QHSxuEa1

Is there any way to view the delete, insert, and update statements that the database has executed?

| username: Jasper | Original post link

To see everything, you can only enable the general log, but it is quite resource-intensive and consumes storage space.
You can refer to the following link:

| username: tidb菜鸟一只 | Original post link

To trust the logs, you must enable the general log, but the cost is high, especially in terms of I/O.

| username: 普罗米修斯 | Original post link

View the system table INFORMATION_SCHEMA.STATEMENTS_SUMMARY

| username: linnana | Original post link

There is also the system history table. I don’t know how long the logs in STATEMENTS_SUMMARY_HISTORY can be retained.

| username: dba远航 | Original post link

This is indeed possible.

| username: wangccsy | Original post link

Performance and functionality are a pair of adversaries.

| username: zhanggame1 | Original post link

The simplest way to capture packets is to try one of the many MySQL packet capture tools available.

| username: 春风十里 | Original post link

You are looking for a database auditing feature. There are specialized database auditing vendors. They usually record and parse SQL traffic through traffic mirroring or agents, allowing you to check who initiated the query, IP, host, operation time, etc. Besides that, whether TiDB Binlog and TiCDC can parse change statements is something I haven’t researched yet, and we need other experts to respond.

| username: 江湖故人 | Original post link

The general log is fine for debugging in a test environment, but it’s not very practical in a production environment. You might consider using a database auditing device with bypass mirroring, which has minimal impact on operations, although they are generally quite expensive.

| username: kelvin | Original post link

It is possible to view the system table INFORMATION_SCHEMA.STATEMENTS_SUMMARY.

| username: 哈喽沃德 | Original post link

It is not recommended to enable it, as it wastes IO.

| username: oceanzhang | Original post link

Either enable binlog or enable general log.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.