从MySQL导出的CSV不会出现在指定的目录中

时间:2015-01-21 19:08:31

标签: mysql sql ssh export

我试图找出通过SSH将MySQL查询结果作为CSV文件导出到桌面的语法。这是我正在尝试的内容:

 SELECT * INTO OUTFILE 'C:\Users\Jim Smith\Desktop\zyzyz.csv'
 FIELDS TERMINATED BY ',' 
 OPTIONALLY ENCLOSED BY '\"'  
 LINES TERMINATED BY '\r\n' 
 from <table> limit 5;

查询本身工作正常,但文件不会出现在桌面上。我应该改变什么来让它出现?

1 个答案:

答案 0 :(得分:0)

尝试这样的事情

LINUS路径

SELECT *
FROM tableName
INTO OUTFILE '/tmp/fileName.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'

这里是参考链接http://www.tech-recipes.com/rx/1475/save-mysql-query-results-into-a-text-or-csv-file/

<强> [编辑]

在任务管理器中查看,如果存在.csv文件的任何实例,则删除然后尝试此

WINDOWS路径

SELECT * INTO OUTFILE 'd:\backups\php\export\data.csv' 
FIELDS TERMINATED BY ',' 
OPTIONALLY ENCLOSED BY '"' 
ESCAPED BY '\' 
LINES TERMINATED BY 'n' 
FROM tableName;