MySQL SELECT INTO 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?
我在服务器上有一个shell脚本。该脚本将csv文件吐出到本地目录。问题是数据库服务器在服务器b上。如何在这样的设置中使用select * into outfile?
I get
Can't create/write to file '/home/username/test.csv/' (Errcode: 2)
Solved load data infile by using 'LOCAL' keyword. Is there something like that for outfile?
使用'LOCAL'关键字解决了加载数据的影响。 outfile有类似的东西吗?
2 个解决方案
#1
12
select into outfile
can only create the file on the server, not the client.
select into outfile只能在服务器上创建文件,而不能在客户端创建。
Here's what the manual recommends for your situation:
以下是手册为您的情况推荐的内容:
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.
如果要在服务器主机以外的某个客户端主机上创建生成的文件,则不能使用SELECT ... INTO OUTFILE。在这种情况下,您应该使用诸如mysql -e“SELECT ...”> file_name之类的命令在客户端主机上生成文件。
http://dev.mysql.com/doc/refman/5.1/en/select.html
更多相关文章
- 有没有一种方法可以在不破坏外键依赖关系的情况下将MySQL数据库
- 如何将xml文件转换为mysql?
- 如何将CSV文件中的值实际分割为MySQL数据库
- linux下mysql配置文件my.cnf详解
- mysql客户端工具使用
- SQLSTATE [HY000] [2002]没有这样的文件或目录
- 解决Linux主机上的 远程MySQL客户端无法连接的问题
- mysql启动脚本——指定数据目录并指定配置文件
- 'mysql'不是内部或外部命令,也不是可运行的程序或批处理文件.