flush logs;默認的日志是mysq..." />
    
    

      1. mysqlbinlog日志恢復(fù)數(shù)據(jù)

        共 3231字,需瀏覽 7分鐘

         ·

        2020-12-20 11:22

        嗨!有段時間沒有更新了,最近有好多人加我說要進群的,由于當(dāng)時建群沒人進,再加上最近一段時間比較忙,就無奈先解散了哈哈哈,抱歉了各位!


        ok,回歸正文

        恢復(fù)數(shù)據(jù)的重要命令如下

        MySQL> flush logs;

        默認的日志是mysql-bin.000001

        現(xiàn)在刷新了重新開啟一個就多了一個mysql-bin.000002


        ./mysqlbinlog --no-defaults binlog日志名,來查看日志

        [root@localhost bin]# ./mysqlbinlog --no-defaults ../var/mysql-bin.000001 | more    //查看bin-log日志的內(nèi)容[root@localhost?bin]#?./mysqlbinlog?--no-defaults?../var/mysql-bin.000001?|?./mysql?-uroot?-p?//恢復(fù)mysql-bin.000001日志的內(nèi)容


        如果需要從某個點恢復(fù)到某個點,用以下操作
        定位:--start-position 開始點

        --stop-position 結(jié)束點--start-date 開始時間--stop-date  結(jié)束時間


        現(xiàn)在恢復(fù)mysql-bin.000002恢復(fù),從134點開始到386結(jié)束?

        [root@localhost bin]# ./mysqlbinlog --no-defaults --start-position 134 --stop-position=386 ../var/mysql-bin.000002 | ./mysql -uroot -p


        mysqlbinlog日志恢復(fù)數(shù)據(jù)實驗
        //查看一下var下面的內(nèi)容,現(xiàn)在是沒有mysql-log.000001類似的binlog日志的

        [root@localhost var]# lsbrocms      ibdata1      ib_logfile1    localhost.pid  mysql-bin.indexbrotherblog  ib_logfile0  localhost.err  mysql          test
        [root@localhost var]# ../bin/mysql -uroot -p //登錄數(shù)據(jù)庫mysql> use test; //使用test數(shù)據(jù)庫mysql> flush logs; //刷新binlog日志,新開一個,現(xiàn)在會在var目錄下面生成一個mysql-bin.000001的文件,以下的操作都會記錄其中


        //創(chuàng)建一個表

        mysql> create table user(    -> id int auto_increment primary key,    -> username char(30),    -> password char(32))    -> engine=myisam default charset=utf8;


        //插入幾條測試數(shù)據(jù)

        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日志,現(xiàn)在會生成一個名為mysql-bin.000002的文件,下面的操作會記錄在mysql-bin.000002的文件中

        mysql> flush logs;


        查詢一下內(nèi)容

        mysql> select * from user;+----+----------+----------+| id | username | password |+----+----------+----------+|  1 | 1        | 2        ||  2 | 1        | 2        ||  3 | 1        | 2        |+----+----------+----------+


        現(xiàn)在將數(shù)據(jù)刪除

        mysql> delete from user;


        將表刪除

        mysql> drop table user;


        查看表里面的內(nèi)容

        mysql> select * from user;mysql> \q
        [root@localhost var]# lsbrocms      ibdata1      ib_logfile1    localhost.pid  mysql-bin.000001  mysql-bin.indexbrotherblog  ib_logfile0  localhost.err  mysql          mysql-bin.000002  test[root@localhost var]# ../bin/mysqlbinlog --no-defaults mysql-bin.000001 | more //查看mysql-bin.000001里面的內(nèi)容[root@localhost var]# ../bin/mysqlbinlog --no-defaults mysql-bin.000002 | more //查看mysql-bin.000002里面的內(nèi)容[root@localhost var]# ../bin/mysqlbinlog --no-defaults mysql-bin.000001 | ../bin/mysql -uroot -p //用mysql-bin.000001來恢復(fù)數(shù)據(jù)Enter password:[root@localhost var]# ../bin/mysql -uroot -p //進數(shù)據(jù)庫查看


        數(shù)據(jù)庫操作

        mysql> use test;mysql> show tables;+----------------+| Tables_in_test |+----------------+| user          |+----------------+1 row in set (0.00 sec)  mysql> select * from user; //查看數(shù)據(jù),數(shù)據(jù)回來了+----+----------+----------+| id | username | password |+----+----------+----------+|  1 | 1        | 2        ||  2 | 1        | 2        ||  3 | 1        | 2        |+----+----------+----------+3 rows in set (0.00 sec)  mysql> \q


        如果需要從某個點恢復(fù)到某個點,用以下操作
        定位:?

        --start-position 開始點
        --stop-position 結(jié)束點
        --start-date 開始時間
        --stop-date? 結(jié)束時間
        ?
        現(xiàn)在恢復(fù)mysql-bin.000002恢復(fù),從134點開始到386結(jié)束?

        [root@localhost bin]# ./mysqlbinlog --no-defaults --start-position 134 --stop-position=386 ../var/mysql-bin.000002 | ./mysql -uroot -p



        瀏覽 120
        點贊
        評論
        收藏
        分享

        手機掃一掃分享

        分享
        舉報
        評論
        圖片
        表情
        推薦
        點贊
        評論
        收藏
        分享

        手機掃一掃分享

        分享
        舉報
          
          

            1. 一级A片逼 | 免费韩国高清理伦片大全 | 免费荫蒂添的好舒服视频 | 免费一级婬片A片AAA小说软件 | 成人永久免费视频在线观看网站 |