您的位置:首页 > 数据库 > MySQL

Mysql 导出txt格式

2015-07-30 15:20 676 查看
Mysql 导出txt格式


1. select display_name, alias, address  from nagios_hosts into outfile '/tmp/test2.txt'; 
导出文件格式:
192.26.1.180.app.rhl6.4       管理员:       192.26.1.180
192.26.1.181.app.rhl6.4       管理员:       192.26.1.181




可以指定间隔
2.mysqldump -u root -p123456 test test2 -t -T /tmp/ --fields-terminated-by=',' --lines-terminated-by='\n'


test  数据库名字


test2 表名字


-t 不导出create信息


-T 指定导出的位置(目录),文件命令方式:表名.txt 自动生成的


--fields-enclosed-by=\" 


--fields-terminated-by=, 列间隔用,表示


--fields-terminated-by=name 
                      Fields in the output file are terminated by the given
                      string.
--fields-enclosed-by=name 
                      Fields in the output file are enclosed by the given
                      character.
--fields-optionally-enclosed-by=name 
                      Fields in the output file are optionally enclosed by the
                      given character.
--fields-escaped-by=name 
                      Fields in the output file are escaped by the given
                      character.




--lines-terminated-by='\n' 行间隔用回车表示
--lines-terminated-by=name 
                      Lines in the output file are terminated by the given
                      string.


linux系统里提供的文件转化编码的命令iconv,使用如下:


iconv -t utf-8 -f gb2312 -c my_database.sql > new.sql
-f  原编码
-t  目标编码
-c 忽略无法转换的字符

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29500582/viewspace-1756727/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29500582/viewspace-1756727/

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: