MySql error 1 (hy000) can’t create/write to file (errcode 13)


Recently when I am exporting mysql command output to csv file I got following error.

ERROR 1 (HY000): Can’t create/write to file (Errcode: 13)

Here I am trying to write output to /home/someuser/somefile.csv I got this error.

After exploring a bit about the error I got to know is instead of writing to /home/someuser/somefile.csv we have to write to file /tmp/somefile.csv.

So I changed the output file to /tmp/somefile.csv in my sql command and its worked.

The reason for the error is permissions. While writing mysql command output into a directory we need have all permissions to that directory.

By default /tmp directory in Linux will have all permissions(777), so we need to write into /tmp directory.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s