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 忽略无法转换的字符
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/
相关文章推荐
- mysql&Oracle导入导出txt格式的数据
- mysql导出文件到txt并指定字段分隔符;mysql导出到xls文件sql试例
- Bash中使用MySQL导入导出CSV格式数据[转]
- mysql 导出数据到txt文件
- 如何将mysql表结构导出成Excel格式的(并带备注)
- Qt的文件导入和导出txt格式;
- mysql 查询结果 导出 excel格式并解决乱码问题
- mysql 导出 导入 数据到 txt
- Table表格导出为Excel、csv、txt、sql、json、xml、Word格式
- ASP.NET按格式导出到TXT文件
- mysql 查询结果 导出 excel格式并解决乱码问题
- 如何将mysql表结构导出成Excel格式的(并带备注)
- 以excel格式导出mysql表
- MYSQL导出CSV的2种格式
- MySQL导入导出txt(csv)
- 导入导出:数据库导出Txt文本文件格式校验[原创]
- mysql>导出数据为txt时报错:The MySQL server is running with the --secure-file-priv option so it cannot execut
- mfc 导出数据保存成excel和txt格式
- 如何将mysql表结构导出成Excel格式的(并带备注)
- mysql 查询结果 导出 excel格式并解决乱码问题