Question

When I run

mysql> select * into outfile "/home/akihirom/file1.txt" from BAIT_INTERACTION;

I get the following error:

ERROR 1 (HY000): Can't create/write to file '/home/akihirom/file1.txt' (Errcode: 13)

This happens even as root, in mysql or on the system itself. Does anyone know why this may be happening? Thanks

Was it helpful?

Solution 2

I was able to do the same thing using mysql dump by dumping the contents of the select statement to a file:

mysql -u USERNAME --password=PASSWORD --database=DATABASE --execute='SELECT `FIELD`, `FIELD` FROM `TABLE` LIMIT 0, 10000 ' -X > file.xml

Where I got the idea from

OTHER TIPS

I merged both examples into one and came up with the following that I used for a capistrano task. I was able to invoke a shell and run this from the command line.

mysql -uUSERNAME --database=${DBNAME} --execute=" SELECT * FROM ${TBNAME} INTO OUTFILE '/tmp/dumps/DBNAME.out' "

I added spacing before double quotes so you could see syntax differences.

Respect to ERROR 1 (HY000): Can't create/write to file '/home/akihirom/file1.txt' (Errcode: 13)
use only ' file1.txt' because server only writes on /var/lib/mysql/DB (where DB is a directory named as the data base) and later if you are root, go to there and manage the file as your needs. You can use file1.cvs too; it works the same as file1.txt

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top