读书人

mysql远程查询指定分隔符 结果输出解决

发布时间: 2012-11-10 10:48:51 作者: rapoo

mysql远程查询指定分隔符 结果输出
mysql客户端在机子a上,server在机子b上。现在需要在a上远程查询b中的表,指定分隔符将表中的域分割,结果输出到a上的一个文件中。请问大侠们sql语句怎么写
试过这样的一个语句:
/usr/bin/mysql -uroot -p123456 -P5029 -h 10.11.200.79 -D ib_2012101724 -N -e"select * from cpc limit 1000 into outfile 'new' fields terminated by '\3'"
但是new file是在远程机子上的


[解决办法]
试试mysqldump的这几个选项

--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.

[解决办法]
mysqldump -T
[解决办法]
/usr/bin/mysql -uroot -p123456 -P5029 -h 10.11.200.79 -D ib_2012101724 -N -e"select * from cpc limit 1000 " > new.txt

读书人网 >Mysql

热点推荐