mysqlbinlog

mysqlbinlog恢复MySQL

非 Y 不嫁゛ 提交于 2020-12-18 04:11:18
#mysqlbinlog恢复MySQL 是否启用了日志 SHOW VARIABLES LIKE 'log_bin'; 怎样知道当前的日志 SHOW master STATUS; 看二进制日志文件用mysqlbinlog mysqlbinlog mail-bin.000001 如果MySQL服务器启用了二进制日志,你可以使用 mysqlbinlog 工具来恢复从指定的时间点开始 (例如,从你最后一次备份)直到现在或另一个指定的时间点的数据。 要想确定当前的二进制日志文件的文件名,输入下面的MySQL语句: SHOW BINLOG EVENTS G; ##指定恢复时间 假设在今天上午10:00(今天是2015年11月4日),执行SQL语句来删除一个大表。要想恢复表和数据,你可以恢复前晚上的备份,并输入: mysqlbinlog --stop-date="2015-11-04 9:59:59" --database=$DB_NAME $BINLOG --result-file=$SQL_FILE 执行恢复特定时间段内的数据: mysqlbinlog --start-date="2015-11-04 8:59:59" --stop-date="2015-11-04 9:59:59" --database=$DB_NAME $BINLOG --result-file=$SQL_FILE #

MySQL下bin-log的三种模式(ROW、Statement、Mixed)

天涯浪子 提交于 2020-03-05 23:13:16
MySQL的bin-log日志备份有三种模式,分别是: ROW、Statement、Mixed 一、Row 基于行的复制(row-based replication,RBR) 日志中会记录成每一行数据被修改成的形式,然后在slave端再对相同的数据进行修改,只记录要修改的数据,只有value,不会有sql多表关联的情况。 优点: 在row模式下,bin-log中可以不记录执行的sql语句的上下文相关信息,仅仅需要记录哪一条记录被修改了,修改成什么信样了,所以row的日志内容会非常清楚的记录下每一行数据修改的细节,非常容易理解。而且不会出现在某些特定情况下的存储过程和function,以及trigger的调用和处罚无法被正确问题。 缺点:在row模式下,所有执行的语句当记录到日志中的时候,都将以每行记录的修改来记录,这样可能会产生大量的日志内容。 二、Statement 基于SQL语句的复制(statement-based replication,SBR) 每一条会修改数据的sql都会记录到master的binlog中,slave在的时候sql进程会解析成和原来master端相同的sql再执行。 优点: 在Statement模式下首先就是解决了row模式下的缺点,不需要记录记录每一行日志的变化,减少了bin-log日志量,节省了I/O以及存储资源,提高性能

MariaDB 10.2.10 writing double binlog entries in mixed format

不打扰是莪最后的温柔 提交于 2019-12-24 21:28:31
问题 I am using MariaDB 10.2.10 under Debian 9 in Master/Slave replication. I am experiencing problems with replication since the slave is refusing replication due to 1062 duplicate key errors. After a long time of investigation I found, that the binlog of the master contains the same INSERT statement twice. It is written in statement AND row based format. binlog_format is set to MIXED. I had a look at general log - the INSERT statement was only commited once. Heres the outpout of mysqlbinlog: #

init_connect + binlog 记录 mysql 操作日志

人走茶凉 提交于 2019-12-03 15:12:32
init_connect + binlog 记录 mysql 操作日志 简介 mysql 的 init_connect 变量是每个客户端连上数据库服务器时执行的一组数据,这组数据可以是一个或者多个sql语句。 A string to be executed by the server for each client that connects. The string consists of one or more SQL statements, separated by semicolon characters. mysql 的 binlog 日志用于记录所有更新了数据库内容的sql语句,以事件的形式保存。 The server's binary log consists of files containing “events” that describe modifications to database contents. 一、记录连接信息 创建表存放日志 CREATE DATABASE accesslog; CREATE TABLE accesslog.accesslog ( `id` INT (11) PRIMARY KEY auto_increment, `time` TIMESTAMP, `localname` VARCHAR (30), `matchname`