Can't create/write to file - Error code 13 in linux

Haseena picture Haseena · Sep 26, 2012 · Viewed 14.8k times · Source

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 test_table( testId int PRIMARY KEY,  testName VARCHAR(20) ) DATA DIRECTORY = '/home/Test/Sample/data';

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

What I can do??? Please give me any valuable suggestions....

Answer

Jones Agyemang picture Jones Agyemang · Jan 25, 2013
mysql> create table test_table( testId int PRIMARY KEY,  testName VARCHAR(20) ) 
       DATA DIRECTORY = '/home/Test/Sample/data';

Write as:

mysql> create table test_table( testId int PRIMARY KEY,  testName VARCHAR(20) ) 
       DATA DIRECTORY = '/tmp/data';

To make life easier do try storing to the '/tmp' directory as mysql has access to this directory rather than fumbling around with (chown) changing ownership.