Sunday, 15 July 2012

linux - MySQL OUTFILE query complains that "file already exists" but the file does not exist at all -



linux - MySQL OUTFILE query complains that "file already exists" but the file does not exist at all -

i writing simple shell script dump table csv file. here part of it:

day=`/bin/date +'%y-%m-%d'` file="/tmp/table-$day.csv" rm $file query="select * table outfile '$file' fields terminated ',' enclosed '\"' lines terminated '\\n'" echo "$query" | mysql <connection_parameters>

i set in rm $file create sure file not exist prior query's execution.

however, when execute script, conflicting messages:

rm: cannot remove `/tmp/table-2013-02-08.csv': no such file or directory error 1086 (hy000) @ line 1: file '/tmp/table-2013-02-08.csv' exists

i cannot find outfile anywhere in machine.

so wrong.. ?

thank you.

i have found answer.

outfile creates file on mysql server, rather on mysql client's machine.

mysql linux

No comments:

Post a Comment