Mysql – How to find MYSQL Logs for Drop Delete Record

MySQL

I am using SQlyog Ultimate for Mysql GUI. I want to know who is deleting, Dropping table and record. I want to track the User Ip and Name.

If there is any method to track please share with me.

I found some Link but not able to understand
How to show the last queries executed on MySQL?

Thanks
Sitansu

Best Answer

You must enable query logging on server as described on the official page:

https://dev.mysql.com/doc/refman/5.7/en/server-logs.html

Here general logging is the easiest approach that can be used to resolve your objective. Link shared by you shows two different methods of achieving the same. You can use following queries as root user to get what you want

SET GLOBAL log_output = 'TABLE';
SET GLOBAL general_log = 'ON';    

select event_time,user_host,argument
from mysql.general_log
where command_type='Query' and 
upper(argument) rlike '(DROP|DELETE|TRUNCATE)+';

Beware that it will fill server disk space very faster.