CREATE TABLE IF NOT EXISTS `runoob_tbl`( `runoob_id` INT UNSIGNED AUTO_INCREMENT, `runoob_title` VARCHAR(100) NOT NULL, `runoob_author` VARCHAR(40) NOT NULL, `submission_date` DATE, PRIMARY KEY ( `runoob_id` ) )ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO runoob_tbl (runoob_title, runoob_author, submission_date) VALUES ("学习 PHP", "菜鸟教程", NOW());
INSERT INTO runoob_tbl (runoob_title, runoob_author, submission_date) VALUES ("学习 java", "菜鸟教程", NOW());
INSERT INTO runoob_tbl (runoob_title, runoob_author, submission_date) VALUES ("学习 mysql", "菜鸟教程", NOW());
所有库--------------------------------------------------------------------------------------------------------------------
mysqldump -uroot -proot.123 -h109.105.4.65 -P32770 -A --set-gtid-purged=OFF --opt > /root/test/dump/test1.dump
mysql -uroot -proot.123 -h109.105.4.65 -P32773 < /root/test/dump/test1.dump
mysqldump -uroot -proot.123 -h109.105.4.65 -P32770 -A --set-gtid-purged=OFF --opt | gzip > /root/test/dump/test1.dump.gz
gunzip < /root/test/dump/test1.dump.gz | mysql -uroot -proot.123 -h109.105.4.65 -P32773
单个库----------------------------------------------------------------------------------------------------------------------
mysqldump -uroot -proot.123 -h109.105.4.65 -P32770 mhc --set-gtid-purged=OFF --opt | gzip > /root/test/dump/test1_mhc.dump.gz
mysql> create database if not exists mhc;
gunzip < /root/test/dump/test1_mhc.dump.gz | mysql -uroot -proot.123 -h109.105.4.65 -P32773 mhc
多个库----------------------------------------------------------------------------------------------------------------------
mysqldump -uroot -proot.123 -h109.105.4.65 -P32770 -B mhc mhc2 --set-gtid-purged=OFF --opt | gzip > /root/test/dump/test1_multi.dump.gz
gunzip < /root/test/dump/test1_multi.dump.gz | mysql -uroot -proot.123 -h109.105.4.65 -P32773
error:
[root@mhc dump]# mysqldump -uroot -proot.123 -h109.105.4.65 -P32770 -B mhc mhc2 mhc3 --set-gtid-purged=OFF --opt | gzip > /root/test/dump/test1_multi.dump.gz
Warning: Using a password on the command line interface can be insecure.
mysqldump: Got error: 1049: Unknown database 'mhc3' when selecting the database
单库单表------------------------------------------------------------------------------------------------------------------------
mysqldump -uroot -proot.123 -h109.105.4.65 -P32770 mhc2 runoob_tbl --set-gtid-purged=OFF --opt | gzip > /root/test/dump/test1_mhc2_runoob_tbl.dump.gz
create database if not exists mhc2;
gunzip < /root/test/dump/test1_mhc2_runoob_tbl.dump.gz | mysql -uroot -proot.123 -h109.105.4.65 -P32773 mhc2
单库多表-------------------------------------------------------------------------------------------------------------------------
mysqldump -uroot -proot.123 -h109.105.4.65 -P32770 mhc2 runoob_tbl runoob_tbl2 --set-gtid-purged=OFF --opt | gzip > /root/test/dump/test1_mhc2_multi.dump.gz
create database if not exists mhc2;
gunzip < /root/test/dump/test1_mhc2_multi.dump.gz | mysql -uroot -proot.123 -h109.105.4.65 -P32773 mhc2
------------------------------------------------------------------------------------------------------------------------------------
tasks/dump-job-info
export
{"Parameters":{"filename":"test1.sql" ,"database":"mhc","storage":{"name":"manta","bucket":"dumps"}},"Action":"export_data","Status":"Prepare"}
{"Parameters":{"filename":"test1.sql" ,"database":"mhc","table":["runoob_tbl"],"storage":{"name":"manta","bucket":"dumps"}},"Action":"export_data","Status":"Prepare"}
{"Parameters":{"filename":"test1.sql" ,"database":"mhc","table":["runoob_tbl"],"storage":{"name":"local","bucket":"dumps"}},"Action":"export_data","Status":"Prepare"}
import
{"Parameters":{"filename":"test1.sql" ,"database":"mhc2","storage":{"name":"manta","bucket":"dumps"}},"Action":"import_data","Status":"Prepare"}
{"Parameters":{"filename":"test2.sql" ,"database":"mhc2","storage":{"name":"local","bucket":"dumps"}},"Action":"import_data","Status":"Prepare"}
backup
backup-job-info
{"Status":"Prepare", "Backup_id":"backup_test1"}
对于含有二进制数据的表
mysqldump -h172.31.1.17 -uadmin -p*** kdts job_types --opt --hex-blob > job_types.sql