Description:
SELECT INTO OUTFILE 'file' saves the file in the directory of the current database.
SELECT INTO OUTFILE './file' saves the file in @@datadir.
SELECT INTO OUTFILE '../file' or './path/to/file' or '../path/to/file' saves the file in the given directory, relative to @@datadir.
This inconsistency is a bit surprising and it's not documented at http://dev.mysql.com/doc/refman/5.1/en/select.html . Not sure if this is a server bug or a documentation bug.
How to repeat:
==== BEGIN test case ====
USE test;
SELECT 1 INTO OUTFILE '1-1';
SELECT 2 INTO OUTFILE './1-2';
SELECT 3 INTO OUTFILE '../1-3';
==== END test case ====
Run the test case and then 'find . -name 1-*'. This is what I see in 5.1-bugteam:
./var/mysqld.1/1-3
./var/mysqld.1/data/test/1-1
./var/mysqld.1/data/1-2