MySQL binlogs 似乎不完整?

MySQL binlogs 似乎不完整?

我创建了一个数据库、一个表并插入了一些数据,并binlog.0000001在我的日志文件夹中找到了这些数据,但是当我这样做时mysqlbinlog binlog.0000001,它只显示下面的内容,似乎不完整:(日志目录中只有两个文件binlog.000001 binlog.index:)

/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#120924 21:12:56 server id 1  end_log_pos 107   Start: binlog v 4, server v 5.5.24-0ubuntu0.12.04.1-log created 120924 21:12:56 at startup
# Warning: this binlog is either in use or was not closed properly.
ROLLBACK/*!*/;
BINLOG '
GAVhUA8BAAAAZwAAAGsAAAABAAQANS41LjI0LTB1YnVudHUwLjEyLjA0LjEtbG9nAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAYBWFQEzgNAAgAEgAEBAQEEgAAVAAEGggAAAAICAgCAA==
'/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;

如果该警告是导致该问题的原因:Warning: this binlog is either in use or was not closed properly.

我该如何强制close记录?

编辑

命令执行后flush logs,看到有“0 行”受到影响,并且出现了一些新文件,binlog.000001 binlog.000002 binlog.000003 binlog.000004 binlog.index其内容与几乎相同binlog.000001

现在我删除了数据库,并尝试使用它来恢复它mysqlbinlog binlog.0* | mysql -u root -p,但是数据库没有恢复。

编辑2

[mysqld]
user        = mysql
pid-file    = /var/run/mysqld/mysqld.pid
socket      = /var/run/mysqld/mysqld.sock
port        = 3306
basedir     = /usr
datadir     = /var/lib/mysql
tmpdir      = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking

log-bin=/var/log/mysql/binlog
binlog-do-db=mydb

bind-address        = 127.0.0.1
key_buffer      = 16M
max_allowed_packet  = 16M
thread_stack        = 192K
thread_cache_size       = 8
myisam-recover         = BACKUP
query_cache_limit   = 1M
query_cache_size        = 16M
expire_logs_days    = 10
max_binlog_size         = 100M

PS /var/log/mysql{.err,.log} 都是空的

答案1

binlog-do-db=mydb

@ErikA 对,名字不同,我指定了'mydb',但没有看到任何以此为前缀的东西

您使用哪种 binlog 格式:基于语句还是基于行?

  • 基于语句的日志记录:只有具有默认数据库的语句才会mydb写入二进制日志。
  • 基于行的日志记录:仅记录属于的表的更改mydb,默认数据库没有影响。

看一眼更多细节。

PS/var/log/mysql{.err,.log}均为空

指定log-error选项mysqld,然后重新启动 MySQL 并重试。

相关内容