Linux – ERROR 1 (HY000): Can’t create/write to file (Error code :13)

linuxMySQLsql

Iam trying to create a mysql table in linux with changing data directory to another location. The selected forlder having full permission. But I got an error 'Can't create/write to file'. I googled and found that this error related to permission denied. I can change the owner permission of the folder to root using chown command. But it still showing the same error.

mysql> create table table123(Id int PRIMARY KEY, Name VARCHAR(20)) DATA DIRECTORY = '/home/test/Sample';

ERROR 1 (HY000): Can't create/write to file '/home/test/Sample/table123.MYD' (Errcode: 13)

When change the data directory location to /var/tmp/Sample, then the table become created.

Why the table not created in the location '/home/test/Sample' ???

Using ubuntu 10.04.
Permission of actual data directory is 700, owner : mysql, group : mysql

Best Answer

You should change owner of new location to mysql user (chown mysql.mysql /data/directory). In simple copy owner ond permision from actual data directory.

EDIT: Set up permision on new data directory using chmod 755 /data/directory

Related Topic