ITPub博客

首页 > 数据库 > MySQL > Mysql 导出txt格式

Mysql 导出txt格式

原创 MySQL 作者:Michael_DD 时间:2015-07-30 15:20:59 0 删除 编辑
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博客 ” ,链接:https://blog.itpub.net/29500582/viewspace-1756727/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-02-22

  • 博文量
    326
  • 访问量
    2671972