Where can I see who deleted the data in TiDB?

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

Original topic: TiDB在哪里能看到是谁删除了数据

| username: 大飞飞呀

[TiDB Usage Environment] Production Environment
[TiDB Version]
[Reproduction Path] What operations were performed when the issue occurred
[Encountered Issue: Issue Phenomenon and Impact]

Hope to find out which user deleted the data

[Resource Configuration]
[Attachment: Screenshot/Log/Monitoring]

| username: Holland | Original post link

If tidb_general_log is enabled in TiDB, it can be found in the logs of the TiDB node.
show variables like “%tidb_general_log%”;

| username: DBRE | Original post link

If the general log is not enabled, check if the slow log can be found.

| username: 裤衩儿飞上天 | Original post link

  1. The enterprise edition has an audit function, which can be checked;

  2. The community edition can enable the general log, but it affects performance, so be cautious in a production environment;

  3. You can try the audit function of proxysql.

| username: Holland | Original post link

Isn’t there a record of SQL in the dashboard? Go check it out there?

| username: 胡杨树旁 | Original post link

It seems that the dashboard records execution times greater than a certain threshold. If you delete SQL execution time segments, it probably won’t be recorded.

| username: tidb狂热爱好者 | Original post link

The dashboard can show the full SQL for the past few hours.

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

Here

| username: 胡杨树旁 | Original post link

Learned, thank you.

| username: wisdom | Original post link

The best solution is to use database auditing features to complete the application. ProxySQL is an open-source solution, but when using ProxySQL for database auditing, while the auditing metrics are effective, it tends to excessively split SQL operations and include a large number of SQL execution operations containing sensitive information. This results in redundant operation logs being recorded in the logs.

| username: system | Original post link

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