Register changes in MySQL

0

I need to register all changes to the database , such as UPDATE , INSERT and etc, so that I can restore the last backup and > run the queries from the last backup , manually deleting the unwanted queries.

I read about the MySQL binary log , but is it possible to delete unwanted queries and open the log file amicably for editing?

I need something similar to this:

-- [...]
-- 2017-04-11 22:07:32
UPDATE foo SET bar = 'fubá';
-- 2017-04-11 22:08:07
DELETE FROM tabela WHERE id = 127;
-- [...]

MySQL 5.7.14 in Windows

    
asked by anonymous 12.04.2017 / 04:14

1 answer

1

Good morning,

I need to register all the changes in the database, such as UPDATE, INSERT and etc »I suggest you do this on your own, create a log or similar table with the desired information like date and time, description, operation performed and which user. I've been doing this for a number of years and the logs have already saved me from typical situations like "customer X has gone ..."

Now, so that I can restore the last backup and run the queries from the last backup seems much more complicated. I suggest you schedule backup dumps every hour, or at ideal frequency, and have these dumps as a restore option.

But is it possible to delete unwanted queries and open the log file in a friendly way for editing? »I may be wrong, but reading so seems like a" magic solution "to solve a situation very complex. I would try with the backup dumps and, if necessary, have the queries in the log table and run them in a maintenance routine. But again, I would implement this via programming, for example in PHP.

I consider it potentially dangerous to manually edit backup SQLs before doing a restore, I try to avoid this approach.

Good luck!

    
12.04.2017 / 15:33