CodeMed
CodeMed

Reputation: 9189

outfile not in expected location despite specifying path

I ran the following command in the MySQL command line client, but I cannot find the outfile:

SELECT my_fieldname INTO OUTFILE 'D:\mypath\my_filename.txt'  
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\\n'  
FROM my_tablename;  

The command line prints out the following confirmation that the command ran properly:

Query OK, 9889 rows affected (0.02 sec)

But the file is not visible in D:\mypath\my_filename.txt and a search for my_filename.txt in the searchbox in the windows start menu does not produce any results.

This is being run on an instance of MySQL on my local development machine running Windows 7.

Where can I find the outfile? Or how can I change my command so that the outfile is actually created?

Upvotes: 0

Views: 50

Answers (1)

Barmar
Barmar

Reputation: 780818

You need to escape backslashes in strings:

SELECT my_fieldname INTO OUTFILE 'D:\\mypath\\my_filename.txt'

or switch to forward slashes:

SELECT my_fieldname INTO OUTFILE 'D:/mypath/my_filename.txt'

Also, make sure that the MySQL server process is allowed to write into D:\mypath.

Upvotes: 2

Related Questions