91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

mysql數據庫mysqlbinlog二進制日志文件挖掘

發布時間:2020-08-07 19:14:18 來源:ITPUB博客 閱讀:221 作者:jiage_Daniel 欄目:MySQL數據庫

點擊(此處)折疊或打開

  1. 1.查看mysql數據庫是否開啟二進制日志log_bin的value值為ON為開啟

  2. mysql> show variables like 'log_%';
  3. +----------------------------------------+-------------------------------------+
  4. | Variable_name | Value |
  5. +----------------------------------------+-------------------------------------+
  6. | log_bin | ON |
  7. | log_bin_basename | /data/db/mysql/3306/mysql-bin |
  8. | log_bin_index | /data/db/mysql/3306/mysql-bin.index |
  9. | log_bin_trust_function_creators | OFF |
  10. | log_bin_use_v1_row_events | OFF |
  11. | log_builtin_as_identified_by_password | OFF |
  12. | log_error | /data/db/mysql/3306/mariadb.log |
  13. | log_error_verbosity | 3 |
  14. | log_output | FILE |
  15. | log_queries_not_using_indexes | OFF |
  16. | log_slave_updates | OFF |
  17. | log_slow_admin_statements | OFF |
  18. | log_slow_slave_statements | OFF |
  19. | log_statements_unsafe_for_binlog | ON |
  20. | log_syslog | OFF |
  21. | log_syslog_facility | daemon |
  22. | log_syslog_include_pid | ON |
  23. | log_syslog_tag | |
  24. | log_throttle_queries_not_using_indexes | 0 |
  25. | log_timestamps | UTC |
  26. | log_warnings | 2 |
  27. +----------------------------------------+-------------------------------------+
  28. 21 rows in set (0.01 sec)

  29. 2.查看時間

  30. mysql> select now();
  31. +---------------------+
  32. | now() |
  33. +---------------------+
  34. | 2017-10-20 19:26:55 |
  35. +---------------------+
  36. 1 row in set (0.00 sec)

  37. 3.查看bin日志文件

  38. mysql> show master logs;
  39. +------------------+-----------+
  40. | Log_name | File_size |
  41. +------------------+-----------+
  42. | mysql-bin.000044 | 870441798 |
  43. +------------------+-----------+
  44. 1 rows in set (0.00 sec)

  45. 4.創建測試表插入數據
  46. mysql> create table t(id int,name varchar(10));
  47. Query OK, 0 rows affected (0.26 sec)
  48. mysql> select * from t;
  49. Empty set (0.00 sec)

  50. mysql> insert into t(id,name)values (1,'a');
  51. Query OK, 1 row affected (0.00 sec)

  52. mysql> insert into t(id,name)values (1,'a');
  53. Query OK, 1 row affected (0.01 sec)

  54. mysql> insert into t(id,name)values (2,'b');
  55. Query OK, 1 row affected (0.00 sec)

  56. mysql> insert into t(id,name)values (2,'b');
  57. Query OK, 1 row affected (0.00 sec)

  58. mysql> insert into t(id,name)values (3,'c');
  59. Query OK, 1 row affected (0.00 sec)

  60. mysql> insert into t(id,name)values (3,'c');
  61. Query OK, 1 row affected (0.01 sec)

  62. mysql> select * from t;
  63. +------+------+
  64. | id | name |
  65. +------+------+
  66. | 1 | a |
  67. | 1 | a |
  68. | 2 | b |
  69. | 2 | b |
  70. | 3 | c |
  71. | 3 | c |
  72. +------+------+
  73. 6 rows in set (0.00 sec)

  74. mysql> insert into t select * from t;
  75. Query OK, 6 rows affected (0.00 sec)
  76. Records: 6 Duplicates: 0 Warnings: 0

  77. mysql> select * from t;
  78. +------+------+
  79. | id | name |
  80. +------+------+
  81. | 1 | a |
  82. | 1 | a |
  83. | 2 | b |
  84. | 2 | b |
  85. | 3 | c |
  86. | 3 | c |
  87. | 1 | a |
  88. | 1 | a |
  89. | 2 | b |
  90. | 2 | b |
  91. | 3 | c |
  92. | 3 | c |
  93. +------+------+
  94. 12 rows in set (0.00 sec)



  95. 5.刪除數據
  96. mysql> select now();
  97. +---------------------+
  98. | now() |
  99. +---------------------+
  100. | 2017-10-20 19:27:46 |
  101. +---------------------+
  102. 1 row in set (0.00 sec)

  103. mysql> delete from t;
  104. Query OK, 12 rows affected (0.01 sec)


  105. mysql> flush logs;
  106. Query OK, 0 rows affected (0.02 sec)

  107. mysql> show master logs;
  108. +------------------+-----------+
  109. | Log_name | File_size |
  110. +------------------+-----------+
  111. | mysql-bin.000044 | 870441798 |
  112. | mysql-bin.000045 | 154 |
  113. | mysql-bin.000046 | 2690 |
  114. | mysql-bin.000047 | 448 |
  115. +------------------+-----------+
  116. 4 rows in set (0.00 sec)

  117. 刷新日志后會看到有三個二進制bin文件生成

  118. 6.提取bin文件中的sql(基于時間的數據恢復)
  119. [root@msp binlog]# ls
  120. bak.sql bin.sql test.sql
  121. [root@msp binlog]# mysqlbinlog --start-datetime="2017-10-20 19:26:55" --stop-datetime="2017-10-20 19:27:46" /data/db/mysql/3306/mysql-bin.000045 >/root/binlog/t.sql
  122. [root@msp binlog]# ls
  123. bak.sql bin.sql test.sql t.sql


  124. 7.進行數據恢復

  125. mysql> source /root/binlog/t.sql;
  126. Query OK, 0 rows affected (0.00 sec)

  127. Query OK, 0 rows affected (0.00 sec)

  128. Query OK, 0 rows affected (0.00 sec)

  129. Query OK, 0 rows affected (0.00 sec)

  130. Query OK, 0 rows affected (0.00 sec)

  131. Query OK, 0 rows affected (0.00 sec)

  132. Query OK, 0 rows affected (0.00 sec)

  133. Query OK, 0 rows affected (0.00 sec)

  134. Query OK, 0 rows affected (0.00 sec)

  135. Query OK, 0 rows affected (0.00 sec)

  136. Query OK, 0 rows affected (0.00 sec)

  137. Charset changed
  138. Query OK, 0 rows affected (0.00 sec)

  139. Query OK, 0 rows affected (0.00 sec)

  140. Query OK, 0 rows affected (0.00 sec)

  141. Query OK, 0 rows affected, 1 warning (0.00 sec)

  142. Query OK, 0 rows affected (0.00 sec)

  143. Query OK, 0 rows affected (0.00 sec)

  144. Query OK, 0 rows affected (0.02 sec)

  145. Query OK, 0 rows affected (0.00 sec)

  146. Query OK, 0 rows affected (0.00 sec)

  147. Query OK, 0 rows affected (0.00 sec)

  148. Query OK, 0 rows affected (0.00 sec)

  149. Query OK, 0 rows affected (0.00 sec)

  150. Query OK, 0 rows affected (0.00 sec)

  151. Query OK, 0 rows affected (0.00 sec)

  152. Query OK, 0 rows affected (0.00 sec)

  153. Query OK, 0 rows affected (0.00 sec)

  154. [root@msp binlog]# rm -f t.sql
  155. [root@msp binlog]# ls
  156. bak.sql bin.sql test.sql
  157. [root@msp binlog]# mysqlbinlog --start-datetime="2017-10-20 19:26:55" --stop-datetime="2017-10-20 19:27:46" /data/db/mysql/3306/mysql-bin.000046 >>/root/binlog/t.sql
  158. [root@msp binlog]# ls
  159. bak.sql bin.sql test.sql t.sql
  160. [root@msp binlog]# ll
  161. total 2715356
  162. -rw-r--r--. 1 root root 6834 Oct 19 17:28 bak.sql
  163. -rw-r--r--. 1 root root 2780497429 Oct 19 17:21 bin.sql
  164. -rw-r--r--. 1 root root 9193 Oct 19 17:36 test.sql
  165. -rw-r--r--. 1 root root 2112 Oct 20 19:44 t.sql
  166. [root@msp binlog]# mysqlbinlog --start-datetime="2017-10-20 19:26:55" --stop-datetime="2017-10-20 19:27:46" /data/db/mysql/3306/mysql-bin.000047 >>/root/binlog/t.sql
  167. [root@msp binlog]# ll
  168. total 2715356
  169. -rw-r--r--. 1 root root 6834 Oct 19 17:28 bak.sql
  170. -rw-r--r--. 1 root root 2780497429 Oct 19 17:21 bin.sql
  171. -rw-r--r--. 1 root root 9193 Oct 19 17:36 test.sql
  172. -rw-r--r--. 1 root root 2448 Oct 20 19:44 t.sql

  173. mysql> source /root/binlog/t.sql;
  174. Query OK, 0 rows affected (0.00 sec)

  175. Query OK, 0 rows affected (0.00 sec)

  176. Query OK, 0 rows affected (0.00 sec)

  177. Query OK, 0 rows affected (0.00 sec)

  178. Query OK, 0 rows affected (0.00 sec)

  179. Query OK, 0 rows affected (0.00 sec)

  180. Query OK, 0 rows affected (0.00 sec)

  181. Query OK, 0 rows affected (0.00 sec)

  182. Query OK, 0 rows affected (0.00 sec)

  183. Query OK, 0 rows affected (0.00 sec)

  184. Query OK, 0 rows affected (0.00 sec)

  185. Charset changed
  186. Query OK, 0 rows affected (0.00 sec)

  187. Query OK, 0 rows affected (0.00 sec)

  188. Query OK, 0 rows affected (0.00 sec)

  189. Query OK, 0 rows affected, 1 warning (0.00 sec)

  190. Query OK, 0 rows affected (0.00 sec)

  191. Query OK, 0 rows affected (0.00 sec)

  192. Query OK, 0 rows affected (0.00 sec)

  193. Query OK, 0 rows affected (0.00 sec)

  194. Query OK, 0 rows affected (0.00 sec)

  195. Query OK, 0 rows affected (0.00 sec)

  196. Query OK, 0 rows affected (0.00 sec)

  197. Query OK, 0 rows affected (0.00 sec)

  198. Query OK, 0 rows affected (0.00 sec)

  199. Query OK, 0 rows affected (0.00 sec)

  200. Query OK, 0 rows affected, 1 warning (0.00 sec)
  201.  
  202. mysql> select * from t;
  203. +------+------+
  204. | id | name |
  205. +------+------+
  206. | 1 | a |
  207. | 1 | a |
  208. | 2 | b |
  209. | 2 | b |
  210. | 3 | c |
  211. | 3 | c |
  212. | 1 | a |
  213. | 1 | a |
  214. | 2 | b |
  215. | 2 | b |
  216. | 3 | c |
  217. | 3 | c |
  218. +------+------+
  219. 12 rows in set (0.00 sec)

  220. 此時數據已經全部恢復到數據刪除之前!!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

犍为县| 海伦市| 苍南县| 郧西县| 阳新县| 福鼎市| 张掖市| 安义县| 长海县| 大姚县| 金秀| 瑞昌市| 新乐市| 郯城县| 思南县| 平阳县| 色达县| 商都县| 鹤壁市| 绵阳市| 水富县| 陵水| 康马县| 拜城县| 札达县| 井研县| 淅川县| 博爱县| 买车| 会宁县| 汾西县| 阿克陶县| 田林县| 开原市| 乌鲁木齐县| 永春县| 麻栗坡县| 南平市| 韩城市| 淳安县| 双牌县|