Can't create/write to file (Errcode: 22)

匿名 (未验证) 提交于 2019-12-03 09:02:45

问题:

Quite new with SQL I'm looking to export some data from a MySQL database into a csv file. I'm working locally (localhost).

Here is my SQL statement:

SELECT DISTINCT * INTO OUTFILE 'C:\Users\Martin\Downloads\result.csv' FROM provider, location, provider_has_location WHERE  provider.idprovider = provider_has_location.provider_idprovider AND location.idLocation = provider_has_location.location_idLocation LIMIT 20 

MySQL return the following error:

Can't create/write to file 'C:UsersMartinDownloads esult.csv' (Errcode: 22)

Thanks for your help.

回答1:

It looks like the back-slashes may be affecting the command. Try using '\\' instead of '\'.



回答2:

SELECT * FROM TableName WHERE condition INTO OUTFILE 'E:/test/filename.csv';

You are having issue with the back slash. Using forward slash resolved the issue in windows machine. But in Ubuntu its not working.

Then I tried with the below mentioned Query and it works:

SELECT * FROM TableName WHERE condition INTO OUTFILE '//tmp/test/filename.csv';

Here the double slash when starting the path is necessary.



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