1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > MySQL–binlog日志恢复数据【MySQL】

MySQL–binlog日志恢复数据【MySQL】

时间:2022-03-28 10:58:46

相关推荐

MySQL–binlog日志恢复数据【MySQL】

数据库|mysql教程

数据恢复,mysql

数据库-mysql教程

MySQL–binlog日志恢复数据 恢复数据的重要命令如下mysql> flush logs; 默认的日志是mysql-bin.000001,现在刷新了重新开启一个就多了一个mysql-bin.000002./mysqlbinlog –no-defaults binlog日志名,来查看日志[root@localhost bin]# ./mysqlbinlog –no-defaults ../var/mysql-bin.000001 | more//查看bin-log日志的内容[root@localhost bin]# ./mysqlbinlog –no-defaults ../var/mysql-bin.000001 | ./mysql -uroot -p //恢复mysql-bin.000001日志的内容如果需要从某个点恢复到某个点,用以下操作定位: –start-position 开始点–stop-position 结束点–start-date 开始时间–stop-date 结束时间 现在恢复mysql-bin.000002恢复,从134点开始到386结束 [root@localhost bin]# ./mysqlbinlog –no-defaults –start-position 134 –stop-position=386 ../var/mysql-bin.000002 | ./mysql -uroot -p /** mysqlbinlog日志恢复数据实验 ****///查看一下var下面的内容,现在是没有mysql-log.000001类似的binlog日志的[root@localhost var]# lsbrocms ibdata1ib_logfile1 localhost.pid mysql-bin.indexbrotherblog ib_logfile0 localhost.err mysqltest[root@localhost var]# ../bin/mysql -uroot -p //登录数据库mysql> use test; //使用test数据库mysql> flush logs; //刷新binlog日志,新开一个,现在会在var目录下面生成一个mysql-bin.000001的文件,以下的操作都会记录其中 //创建一个表mysql> create table user( -> id int auto_increment primary key, -> username char(30), -> password char(32)) -> engine=myisam default charset=utf8;//插入几条测试数据mysql> insert into user(username,password) values(1,2);mysql> insert into user(username,password) values(1,2);mysql> insert into user(username,password) values(1,2);//新开一个binlog日志,现在会生成一个名为mysql-bin.000002的文件,下面的操作会记录在mysql-bin.000002的文件中 mysql> flush logs;//查询一下内容mysql> select * from user;+—-+———-+———-+| id | username | password |+—-+———-+———-+| 1 | 1 | 2 || 2 | 1 | 2 || 3 | 1 | 2 |+—-+———-+———-+mysql> delete from user; //现在将数据删除mysql> drop table user; //将表删除mysql> select * from user; //查看表里面的内容 mysql> /qBye[root@localhost var]# lsbrocms ibdata1ib_logfile1 localhost.pid mysql-bin.000001 mysql-bin.indexbrotherblog ib_logfile0 localhost.err mysqlmysql-bin.000002 test[root@localhost var]# ../bin/mysqlbinlog –no-defaults mysql-bin.000001 | more //查看mysql-bin.000001里面的内容[root@localhost var]# ../bin/mysqlbinlog –no-defaults mysql-bin.000002 | more //查看mysql-bin.000002里面的内容[root@localhost var]# ../bin/mysqlbinlog –no-defaults mysql-bin.000001 | ../bin/mysql -uroot -p //用mysql-bin.000001来恢复数据 Enter password:[root@localhost var]# ../bin/mysql -uroot -p //进数据库查看mysql> use test;mysql> show tables;+—————-+| Tables_in_test |+—————-+| user |+—————-+1 row in set (0.00 sec) mysql> select * from user; //查看数据,数据回来了+—-+———-+———-+| id | username | password |+—-+———-+———-+| 1 | 1 | 2 || 2 | 1 | 2 || 3 | 1 | 2 |+—-+———-+———-+3 rows in set (0.00 sec) mysql> /qBye 如果需要从某个点恢复到某个点,用以下操作定位: –start-position 开始点–stop-position 结束点–start-date 开始时间–stop-date 结束时间 现在恢复mysql-bin.000002恢复,从134点开始到386结束 [root@localhost bin]# ./mysqlbinlog –no-defaults –start-position 134 –stop-position=386 ../var/mysql-bin.000002 | ./mysql -uroot -p

wannacry源码下载,vscode安装pip,ubuntu20.04 下载,tomcat流程原理,sqlite3 c,精确到时分秒的插件,vue三大前端框架,https无法爬虫,php数组判断,seo垃圾,全套炫酷网站,汽车简单网页设计源码,织梦模板高仿d8博客系统,手机前端页面模版,学生信息管理系统jsp代码,一元夺宝 网站程序lzw

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。