mysql导出某库下的数据及表结构(导出的是sql语句):
mysqldump -h$HOST -P$PORT -u$USER -p$PASSWORD $DATABASE >file.sql
mysqldump $DATABASE -h$HOST -P$PORT -u$USER -p$PASSWORD >file.sql
mysql导出某数据库下数据,不导表结构(导出的是sql语句):
mysqldump -h$HOST -P$PORT -u$USER -p$PASSWORD $DATABASE –no-create-info >file.sql
mysql导出表部分数据(导出的是sql语句):
mysqldump -h$HOST -P$PORT -u$USER -p$PASSWORD $DATABASE $TABLE –no-create-info –where “condition” >file.sql
mysql导出replace格式数据(导出的是sql语句):
mysqldump -h$HOST -P$PORT -u$USER -p$PASSWORD -t –replace –skip-extended-insert –default-character-set=gbk
–set-gtid-purged=OFF –skip-disable-keys –skip-lock-tables –skip-add-locks -B $DATABASE –tables table1
table2 table3 > file.sql
mysql导出insert格式数据(导出的是sql语句):
mysqldump -h$HOST -P$PORT -u$USER -p$PASSWORD -t –skip-extended-insert –default-character-set=gbk
–set-gtid-purged=OFF –skip-disable-keys –skip-lock-tables –skip-add-locks -B $DATABASE –tables table1
table2 table3 > file.sql
mysql导出数据:
select * from table INTO OUTFILE >file.sql;
mysql导出数据分割:
mysql -h$HOST -P$PORT -u$USER -p$passwd -N -e “use $DATABASE;set names $ENCORDING;
select comcat(comum1,’|’,column2) from $TABLE ” >file.txt;// 执行命令时忽略列名: 加 -N
mysql快速导入另一个表的数据:
insert into table1 select * from table2;//整表导入
intset into table1(column1,column2…) select column1,column2… from table2;//特定字段导入
mysql导入一个sql文件:
mysql -h$HOST -P$PORT -u$USER -p$PASSWD –default-character-set=gbk -D$DATABASE < $PATH/file.sql
本文地址:https://blog.csdn.net/qq_28123845/article/details/107642364