I was trying to dump my mysql table using the below command
mysqldump --tab=/home/username/Desktop/basic/ --user myusername -p mysql user;
But it returned an error saying
mysqldump: Got error: 1: Can't create/write to file '/home/username/Desktop/basic/user.txt' (Errcode: 13) when executing 'SELECT INTO OUTFILE'
I use Ubuntu 14.04. I have tried to disable apparmor as explained here. But still the error exists. Any other solutions?
Edit
I get the .sql file but not the .txt file
First make sure that
mysql
can write to/home/username/Desktop/basic/
; if you're planning to do multiple dumps in the same directory, a pretty clean way to do it would be to set the ownership of the folder tomysql
and to set the SGID permission on the folder (thanks to muru for this suggestion): this waymysqldump
will be able to write to the folder, but new files will inherit the the group from the parent directory; this has the advantage of leaving to your user read, write, and execute permissions on the dumps.Additionally, make sure that there isn't any file named
user.sql
oruser.txt
present in the target directory before issuing the command; if eithermysql
can't write to the target directory or a file with the same name of one of the expected output files exists before issuing the command,mysqldump
is going to fail.