MySQL update rollback mysqlbinlog reply data

Key documents: https://github.com/danfengcao/binlog2sql

mysqlbinlog: command not found

Open Method: mysql configuration file, locate the # log-bin = mysql-bin, and comments can be canceled.

To use mysqlbinlog, mysqlbinlog in mysql bin directory, the directory after the switch prompt execution mysqlbinlog

-bash: mysqlbinlog: command not found

Command not found, it would first solve the problem, the solution:

find  / -name mysqlbinlog -print

Figure:

Only / www / server / mysql / bin / mysqlbinlog a record, this is my mysql directory

Then mysqlbinlog to be a soft link to / usr / bin

 ln -fs /www/server/mysql/bin/mysqlbinlog /usr/bin

And then perform the find / -name mysqlbinlog -print View

You will find more than one, an error ignored. Now, you can normally use the mysqlbinlog.

My approach is to export sql text, recovery in the local, export method is:

mysqlbinlog /www/server/linshi/mysql-bin.000087 --start-datetime='2018-01-09 00:00:00' --stop-datetime='2018-01-10 00:00:00' > /www/server/linshi/1233.sql

/www/server/linshi/mysql-bin.000087 log file is located

/www/server/linshi/1233.sql position is to be exported

Soon you will see 1233.sql file is finished, switch to the appropriate directory, and then import the database to restore it

Execution of sentence

sudo mysqlbinlog /usr/local/mysql/var/mysql-bin.000116 --start-datetime='2020-04-02 10:00:27' --stop-datetime='2020-04-02 10:18:27'>/tmp/123.sql

 

Get file restore
1, direct recovery
mysqlbinlog /usr/local/mysql/data/binlog.123456 | MySQL -u root -p
2, by location to restore the main parameters [-start -stop-position-position]
mysqlbinlog -stop -position = 368312 -start-position = 368315 /usr/local/mysql/data/binlog.123456 | mysql -u root -p
position here by reading binlog file for viewing, but this must have been that they know operating. If you see the back of said files are garbled or not really look at the issue of sql
3, according to the point in time to recover the main parameters [-start -stop-datetime-datetime]
mysqlbinlog -stop-datetime = "2005-04-20 9 : 59: 59 "-start-datetime =" 2005-04-20 10:01:00 "/usr/local/mysql/data/binlog.123456 | mysql -u root -p
point in time recovery to restore the truth, like location, you must also know the time and to the specific operation is restored to what time of
4, different ways to recover
1, if it is logged into mysql and binlog also cut general binlog directory installs data file directory in mysql on a server under it it can directly recover
this situation can execute commands directly in the MySQL
2, if only to get a binlog file and is in line server need to try to correct the data and then into the production of
This situation can put binlog files to output sql file as you develop:
mysqlbinlog /usr/local/mysql/data/binlog.123456> /tmp/mysql.sql
this output is likely not see anything of value If you want to see the standard sql sql use
mysqlbinlog -base64-output = DECODE-ROWS -v /usr/local/mysql/data/binlog.123456> /tmp/mysql.sql

The above situation may also want to get the sql not need to be replaced, so if less data manually replace @ 1 @ 2 can be recommended if more open source tools mysql2binlog github address: https: //github.com/danfengcao/ binlog2sql

The last point line data must be careful, though there binlog mysql mechanism, but people still want to use it as little as possible!

problem:

sql binlog2sql rollback sql generated found empty, the wrong sql, sql generate rollback when empty, which is why

Is to find the log files, but when generating sql rollback, the generated sql is empty, it was met chiefs welcome you correct me, brother grateful!

my.cnf configuration file as follows:

Reference: https: //blog.csdn.net/flower_vip/article/details/79032999

Reference: https://my.oschina.net/u/3486280/blog/1605031

Mysql binlog view method

Released 2395 original articles · won praise 53 · views 440 000 +

Guess you like

Origin blog.csdn.net/lxw1844912514/article/details/105264966