我创建了一个数据库,一个表并插入了一些数据,并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} 都是空的
您使用的是哪种二进制日志格式:基于语句还是基于行?
mydb
才会写入二进制日志。mydb
,默认数据库没有影响。看看这个了解更多细节。
在 [ ] 部分下指定一个
log-error
选项mysqld
,然后重新启动 MySQL 并重试。