日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > 数据库 >内容正文

数据库

dump mysql database_【MySQL Database】数据迁移工具:mysqldump

發(fā)布時(shí)間:2025/4/16 数据库 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 dump mysql database_【MySQL Database】数据迁移工具:mysqldump 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

[mysql@wallet01 ~]$ mysqldump --help

-u, --user=name 指定連接數(shù)據(jù)庫(kù)服務(wù)器使用的用戶

-p, --password 指定連接數(shù)據(jù)庫(kù)服務(wù)器使用的密碼

-P, --port=# 指定連接數(shù)據(jù)庫(kù)服務(wù)器使用的端口

-h, --host=name 指定連接數(shù)據(jù)庫(kù)服務(wù)器的主機(jī)名

-A, --all-databases 備份全部的數(shù)據(jù)庫(kù)

-B, --databases 備份指定的數(shù)據(jù)庫(kù)

-t, --no-create-info 僅備份表記錄

-d, --no-data 僅備份表結(jié)構(gòu)

-w, --where=name 僅備份表中匹配條件的記錄

-E, --events 備份數(shù)據(jù)庫(kù)的事件

-R, --routines 備份數(shù)據(jù)庫(kù)的存儲(chǔ)過程與函數(shù)

--triggers 備份表的觸發(fā)器

-x, --lock-all-tables 鎖定全部數(shù)據(jù)庫(kù)中的全部表。

-T, --tab=nameCreate tab-separated textfile for each table to given path. (Create .sql and .txt files.)

--fields-terminated-by=nameFields in the output file are terminated by the given string.

--fields-enclosed-by=nameFields in the output file are enclosed by the given character.

--lines-terminated-by=nameLines in the output file are terminated by the given string.

--dump-slave[=#] This causes the binary log position and filename of the

master to be appended to the dumped data output. Setting

the value to 1, will printit as a CHANGE MASTER command

in the dumped data output; if equal to 2, that command

will be prefixed with a comment symbol. This option will

turn --lock-all-tables on, unless --single-transaction is

specified too (in which case a global read lock is only

taken a short time at the beginning of the dump - don't

forget to read about --single-transaction below). In all

cases any action on logs will happen at the exact moment

of the dump.Option automatically turns --lock-tables off.

--master-data[=#] This causes the binary log position and filename to be

appended to the output. If equal to 1, will print it as a

CHANGE MASTER command; if equal to 2, that command will

be prefixed with a comment symbol. This option will turn

--lock-all-tables on, unless --single-transaction is

specified too (in which case a global read lock is only

taken a short time at the beginning of the dump; don't

forget to read about --single-transaction below). In all

cases, any action on logs will happen at the exact moment

of the dump. Option automatically turns --lock-tables

off.

--single-transaction

Creates a consistent snapshot by dumping all tables in a

single transaction. Works ONLY for tables stored in

storage engines which support multiversioning (currently

only InnoDB does); the dump is NOT guaranteed to be

consistent for other storage engines. While a

--single-transaction dump is in process, to ensure a

valid dump file (correct table contents and binary log

position), no other connection should use the following

statements: ALTER TABLE, DROP TABLE, RENAME TABLE,

TRUNCATE TABLE, as consistent snapshot is not isolated

from them. Option automatically turns off --lock-tables.

備份指定的庫(kù)

[mysql@wallet01 ~]$ mysqldump -uroot -p --databases soe > soe.sql

備份指定的表

[mysql@wallet01 ~]$ mysqldump -uroot -p soe customer >customer.sql

僅備份表結(jié)構(gòu)

[mysql@wallet01 ~]$ mysqldump -uroot -p --no-data soe customer >customer.sql

僅備份表記錄

[mysql@wallet01 ~]$ mysqldump -uroot -p --no-create-info soe customer >customer.sql

僅備份表中匹配條件的記錄

[mysql@wallet01 ~]$ mysqldump -uroot -p --where="c_state='z3'" soe customer >customer.sql

還原指定的庫(kù)

[mysql@wallet01 ~]$ mysql -uroot -p soe < soe.sql

還原指定的表

[mysql@wallet01 ~]$ mysql -uroot -p soe < customer.sql

表結(jié)構(gòu)備份為sql文件,表記錄備份為文本文件

[mysql@wallet01 ~]$ mysqldump -uroot -p --tab=/var/lib/mysql-files \

--fields-terminated-by=',' --fields-enclosed-by='"' --lines-terminated-by='\n' soe customer

[mysql@wallet01 ~]$ cd /var/lib/mysql-files

[mysql@wallet01 mysql-files]$ ls -lh

total 165M

-rw-rw-r-- 1 mysql mysql 2.5K Sep 18 10:08 customer.sql

-rw-rw-rw- 1 mysql mysql 165M Sep 18 10:08 customer.txt

還原表結(jié)構(gòu)

[mysql@wallet01 ~]$ mysql -uroot -p soe < customer.sql

還原表記錄

[mysql@wallet01 ~]$ mysqlimport -uroot -p soe \

--fields-terminated-by=',' \

--fields-enclosed-by='"' \

--lines-terminated-by='\n' /var/lib/mysql-files/customer.txt

Enter password:

soe.customer: Records: 300000 Deleted: 0 Skipped: 0 Warnings: 0

《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀

總結(jié)

以上是生活随笔為你收集整理的dump mysql database_【MySQL Database】数据迁移工具:mysqldump的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。