用select...into outfile导出文本文件
select [例名] from table [where 语句]
into outfile'目标文件'[option];
option有5个选项
fields terminated by'字符串':设置字符串为字段的分隔符,默认值为'\t'
fields enclosed by '字符'; 设置字符来括上字段的值,默认情况下不使用任何符号
fields optionallyenclosed by '字符':
用mysqldump命令导出文本文件
#mysqldump -u root-pPassword -T 目标目录 dbnametable[option];
用mysqldump命令导出XML文件
#mysqldump -u root-pPassword -xml|-X dbname table >/*.xml
用mysql命令导出文本文件
mysql -u root-pPassword -e "select 语句" dbname> /name.txt;
[root@node201 ~]#mysql -u root -p123456 -e "select * from user" mysql >/user.txt
用mysql命令导出XML文件
mysql -u root-pPassword --xml|-X -e "select 语句" dbname >/name.xml
用mysql命令导出HTML文件
mysql -u root-pPassword --HTML|-H -e "select 语句" dbname >/name.xml
用load data infile方式导入文本文件
load data [local]infile file into table table [option];
用mysqlimport方式导入文本文件
mysqlimport -u root-pPassword [--LOCAL] dbname file [option]
数据导出:
1.select ...into outfile...来导出数据
mysql>select *from tablename into outfile 'target_file' [option];
2.用mysqldump导出数据为文本
mysqldump -u username -Ttarget_dir dbname tablename tablename[option]
数据导入:
1.load date infile.....
mysql>loaddata [local] infile 'filename' intotable tablename [option]
2.mysqlimport
shell>mysqlimport-u root -p*** [--local] dbname order order_tab.txt [option]