CentOS下Mysql误删恢复

1.确保bin-log开启:mysql> show variables like 'log_bin'; 
没加的,先vi /etc/my.cfg,在配置文件中加上
[mysqld]
log-bin=MySQL-bin (二进制日志名,可以自己定义)


2.在/var/lib/mysql/下找到最新的binlog日志,一般为mysql-bin.00000X
3.按照时间将日志生成sql文件:
mysqlbinlog --no-defaults  --start-date="2017-05-09 16:30:00" --stop-date="2017-05-09 17:00:00" /var/lib/mysql/mysql-bin.000005 >/opt/1.sql


使用mysqlbinlog --start-date="2017-05-09 16:30:00" --stop-date="2017-05-09 17:00:00" /var/lib/mysql/mysql-bin.000005 >/opt/1.sql
会报:mysqlbinlog: unknown variable 'default-character-set=utf8'错误,
解决方案:1.加参数--no-defaults 
                2.在MySQL的配置/etc/my.cnf中将default-character-set=utf8 修改为 character-set-server = utf8


show binlog events in 'mysql-bin.000005'

你可能感兴趣的:(Linux)