MySQL SELECT INTO OUTFILE到其他服务器? [英] MySQL SELECT INTO OUTFILE to a different server?

查看:861
本文介绍了MySQL SELECT INTO OUTFILE到其他服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在服务器a上有一个shell脚本.该脚本将一个csv文件吐出到本地目录.问题是数据库服务器在服务器b上.在这样的设置中,如何使用 select *到outfile 中?

I have a shell script on server a. The script spits out a csv file to a local directory. The problem is the database server is on server b. How do I use select * into outfile in a setup like this?

我知道

Can't create/write to file '/home/username/test.csv/' (Errcode: 2)

使用"LOCAL"关键字解决了加载数据文件中的问题.是否有类似的东西可以胜任?

Solved load data infile by using 'LOCAL' keyword. Is there something like that for outfile?

推荐答案

select into outfile只能在服务器上创建文件,而不能在客户端上创建文件.

select into outfile can only create the file on the server, not the client.

以下是手册针对您的情况所建议的内容:

Here's what the manual recommends for your situation:

如果要创建结果 文件放在其他客户端主机上,而不是 服务器主机,您不能使用SELECT ...进入输出文件.在这种情况下,您 而是应使用诸如 mysql -e"SELECT ...">文件名 在客户端主机上生成文件.

If you want to create the resulting file on some client host other than the server host, you cannot use SELECT ... INTO OUTFILE. In that case, you should instead use a command such as mysql -e "SELECT ..." > file_name to generate the file on the client host.

http://dev.mysql.com/doc/refman/5.1/en/select.html

这篇关于MySQL SELECT INTO OUTFILE到其他服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆