导出:
1.仅仅导出数据到文件中(默认tab分割)
select * from UM_USER into outfile ‘/tmp/UM_USER.txt’;
按指定格式导出 字段分割用 逗号,内容用引号,换行用\n ( CSV 格式)
select * from UM_USER into outfile ‘/tmp/um_1.txt’ FIELDS TERMINATED BY ‘,’ ENCLOSED BY ‘"’ LINES TERMINATED BY ‘\n’; (前边带序号)
select * from UM_USER into outfile ‘/tmp/um_4.txt’ FIELDS TERMINATED BY ‘,’ OPTIONALLY ENCLOSED BY ‘"’ LINES TERMINATED BY ‘\n’;
2.带 建库建表 语句的导出方式
mysqldump -uroot -p -h172.29.4.9 --opt --databases --routines --events --flush-logs --single-transaction --master-data=2 --default-character-set=utf8 bitmap_enterprise | gzip > /tmp/bitmap_enterprise.sql.gz
导入:
1.mysql命令导入
mysql -ua3 -pa32015 -h172.29.4.9 < /tmp/um.sql
2.source导入
source /tmp/um.sql
3.load data导入
load data local infile ‘/tmp/UM_USER_1.txt’ into table UM_USER;