mysql and mysqldump restore accidentally deleted two parameters to understand

mysqldump appreciated that two parameters
--single-transaction
by the export packaged in a transaction so that the data to a consistent snapshot is derived. Only when the table storage engine supports MVCC (currently only InnoDB) can work; other engines can not guarantee that the export is consistent. When exporting turned -single-transaction option, to ensure that the export file is valid (correct table data and binary log position), it is necessary to ensure that no other connections will execute the following statement: ALTER TABLE, DROP TABLE, RENAME TABLE, TRUNCATE TABLE, this will lead to a consistent snapshot failure. When this option is turned on automatically turns off -lock-tables.

-Master-data
this option can add binlog location and file name to the output, if equal to 1, will be printed as a CHANGE MASTER command; if equal to 2, will add annotations prefix. This option automatically opens and -lock-all-tables, unless you also set -single-transaction (in this case, a global read lock will only add a short time at the beginning of the dump, do not forget to read -single- the transaction portion). In any case, all the log operations will take place at the exact time of export. This option will automatically shut down -lock-tables.


Method mysql erroneous recovery
1. Common methods (backup and recovery)
Start of MASTER_LOG_FILE an until Slave = 'mysql-bin.002974', MASTER_LOG_POS = 55,056,952;
recovered to a temporary instance, will accidentally deleted, updated data dump out and returned to examples of old inside.


2. The use of open source tools binlog2sql recovery
binlog2sql DBA is a development company based on public comment by parsing binlog will delete recovery principle to do is swap the insert, the value set field and where conditions update to recover data.

Installation
PIP -R & lt requirments.txt the install
Python binlog2sql.py -h127.0.0.1 -P3307 -udba -p'dbadmin '-dyang -tflashback --start-File =' MySQL-bin.000011 '
used to generate -B recovery sql

Guess you like

Origin www.cnblogs.com/duanzexun/p/10966614.html