pocketfullofcheese pocketfullofcheese - 2 years ago 166
SQL Question

why does SELECT INTO OUTFILE give file exists error even though file does not exist?

The file definitely does not exist, but I am getting an error anyway.

I do:

$ rm /tmp/records_materialized_view.txt;
$ mysql ...

> SELECT * FROM records_materialized_view INTO OUTFILE '/tmp/records_materialized_view.txt';

ERROR 1086 (HY000): File '/tmp/records_materialized_view.txt' already exists

Answer Source

SELECT INTO OUTFILE writes results to a server file.

Are you checking for the file existence on server?

If you want to select into a local file on your client machine, just redirect mysql output:

mysql mydb < script.sql > /tmp/records_materialized_view.txt
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download