Mysql 导出txt格式

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/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值