Outfile local path specification

倖福魔咒の 提交于 2019-12-24 09:49:00

问题


How do i exact to my local machine?

select * into outfile 'C:\Info\table1.txt' fields terminated by ',' from table1;

This query creates under info folder as table1.txt on the server, how do i specify my local machine path here?

Thanks.


回答1:


You can't do it directly. The OUTFILE syntax only applies to the server itself. However, you can do :

c:\> mysql -u username -h nameofserver -p -e "SELECT ... FROM database.table WHERE ..." > c:\info\table1.txt

if you've configured MySQL to allow remote connections from your machine.




回答2:


This query creates under info folder as table1.txt on the server, how do i specify my local machine path here?

If you are accessing the remote machine using SSH, you can't, at least not directly. As far as I know, it is not possible to pipe the result of a INTO OUTFILE operation.

Suggestions for workarounds:

  • Create a network share on your local machine that is reachable by the server (if possible)

  • Create a network share (or FTP account... or WebDAV account...) on the server, store the dump there and fetch it from there



来源:https://stackoverflow.com/questions/3755808/outfile-local-path-specification

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!