6

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....

Haseena
  • 484
  • 2
  • 11
  • 25
  • 2
    does mysql have permission to write into the `Test` user's home directory? Most likely not. Just because `data` is wide open doesn't mean `Test` or `Sample` are. MySQL has to have access rights to the ENTIRE directory tree leading up to where you want the file to go – Marc B Sep 26 '12 at 05:37
  • Thanks for helping.I couldn't gave any permission to Test folder. Now its working. – Haseena Sep 26 '12 at 05:46

1 Answers1

10
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.

d-_-b
  • 21,536
  • 40
  • 150
  • 256
Jones Agyemang
  • 1,230
  • 16
  • 15