Outfile local path specification

2019-08-15 06:37发布

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.

2条回答
太酷不给撩
2楼-- · 2019-08-15 07:24

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

查看更多
倾城 Initia
3楼-- · 2019-08-15 07:26

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.

查看更多
登录 后发表回答