久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

如何理解mysqldump備份

153次閱讀
沒有評論

共計 3763 個字符,預計需要花費 10 分鐘才能閱讀完成。

如何理解 mysqldump 備份,很多新手對此不是很清楚,為了幫助大家解決這個難題,下面丸趣 TV 小編將為大家詳細講解,有這方面需求的人可以來學習下,希望你能有所收獲。

mysqldump 備份

邏輯 innodb 備份 mysql
標準備份
mysqldump -uroot -p123 –default-character-set=utf8 –single-transaction –extended-insert=false –hex-blob –master-data=2 –log-error=/tmp/test.err –routines –triggers –events –quick
–flush-logs –databases test1 t1 test1.sql 

–quick   查詢出來不放在 buffer,直接輸出
–extended-insert=false   導出 insert 語句是多行,并非 insert into t values (),();
–lock-all-tables 將 myisam 表鎖住,保持表的一致性
–single-transaction   將 innodb 表鎖住,保持表的一致性
–master-data=2  file 和 position 的記錄位置 ,2 代表注釋
–databases 導出創建數據庫的語句

恢復

mysql -uroot -p1234356 czb.sql

恢復其他庫

1、將備份里的創建數據語句刪除
2、use‘新庫’
3、在 mysql 數據庫創建新庫
4、mysql -uroot -p123456 新庫名 czb.sql

binlog 追加數據

根據 –master-data 參數備份記錄備份的位置,通過 mysqlbinlog 查看

mysqlbinlog –start-position=3444  -d czb mysql-bin.000003 a.sql

–start-position=3444 //3444 這個值通過備份里的 –master-data 參數得到的

mysql -uroot -p123456
source a.sql

實驗:

[root@mysql_master backup]# mysql -uroot -p123456
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 25
Server version: 5.6.29-log Source distribution

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type help; or \h for help. Type \c to clear the current input statement.

mysql show databases;
+——————–+
| Database           |
+——————–+
| information_schema |
| czb                |
| mysql              |
| performance_schema |
| t                  |
| test               |
+——————–+
6 rows in set (0.00 sec)

mysql use czb
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql show tables;
+——————–+
| Tables_in_czb      |
+——————–+
| F_ORDERINFO_DETAIL |
| t                  |
+——————–+
2 rows in set (0.00 sec)

[root@mysql_master backup]# mysqldump -uroot -p123456 –default-character-set=utf8 –single-transaction –extended-insert=false –hex-blob –master-data=2 –log-error=/tmp/test.err –routines –triggers –events –quick –flush-logs –databases czb t test1.sql 
Warning: Using a password on the command line interface can be insecure.

[root@mysql_master backup]# ls
test1.sql
[root@mysql_master backup]#

以上備份完成

恢復到其他數據庫:

[root@mysql_master backup]# vi test1.sql
#CREATE DATABASE /*!32312 IF NOT EXISTS*/ `czb` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `back`;

[root@mysql_master backup]# mysql -uroot -p123456
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 27
Server version: 5.6.29-log Source distribution

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type help; or \h for help. Type \c to clear the current input statement.

mysql create database back;
Query OK, 1 row affected (0.04 sec)

mysql  

[root@mysql_master backup]# mysql -uroot -p123456 back test1.sql 
Warning: Using a password on the command line interface can be insecure.
以上就是將 czb 庫中的 t 表恢復到 back 庫中

追備份后的增加的數據(通過 binlog)
假如現在備份的表有新的數據插入了。
[root@mysql_master backup]# more test1.sql
— CHANGE MASTER TO MASTER_LOG_FILE= mysql-bin.000004 , MASTER_LOG_POS=120;

[root@mysql_master data]# mysqlbinlog –start-position=120  -d czb /usr/local/mysql/data/mysql-bin.000004 a.sql

[root@mysql_master backup]# mysql -uroot -p123456
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 31
Server version: 5.6.29-log Source distribution

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type help; or \h for help. Type \c to clear the current input statement.

mysql use back

看完上述內容是否對您有幫助呢?如果還想對相關知識有進一步的了解或閱讀更多相關文章,請關注丸趣 TV 行業資訊頻道,感謝您對丸趣 TV 的支持。

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-07-19發表,共計3763字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 盱眙县| 红桥区| 兴业县| 安福县| 紫阳县| 玛沁县| 开原市| 台东市| 沁水县| 巩留县| 祁连县| 黔江区| 涟源市| 保定市| 防城港市| 东兰县| 普兰店市| 湖南省| 黑山县| 安陆市| 措勤县| 长治县| 湄潭县| 汉沽区| 仙居县| 监利县| 平乐县| 张掖市| 合阳县| 崇礼县| 永登县| 报价| 太谷县| 大城县| 印江| 甘泉县| 云阳县| 贵州省| 雅江县| 巩留县| 武宁县|