MySQL select into outfile does not write the file to the directory that I choose
Asked Answered
Z

2

6

The following command:

select * 
  INTO OUTFILE '\home\user1\NetBeansProjects\project1\dumps\theData.csv'
  FIELDS TERMINATED by ','
  LINES TERMINATED BY '\n'
  from database1

Does not write a file called theData.csv to the specified directory.

  1. How do I get this file to be written to the specified directory?
Zeiger answered 16/1, 2013 at 19:7 Comment(2)
you need to ensure mysql has the write permission to the directory. see this for more details dev.mysql.com/doc/refman/5.1/en/select-into.htmlEshelman
What @Eshelman said - check that mysql/mysql has write permission to that folder. Also - this writes to the folder on the mysql server - not to local host.Newsletter
G
3

The path doesn't seem write - if you are on Linux server then I would expect the path with contains slashes and not backslashes, if you are on Windows machine I would expect the driver letter to appears somewhere (and you can't write on a network folder - just local to the DB server machine).

Also, just to eliminate permissions issue or trying to override existing file, try to write to '/tmp/non_existing_file.csv'.

Georgiannegeorgic answered 2/4, 2014 at 19:46 Comment(0)
D
0

Are you using Windows or Linux? You might need to change the back slashes to forward slashes. Also you need to change the settings in MySQL Query browser or Workbench to view this folder as default.

Dishwater answered 19/3, 2014 at 19:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.