Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
share|improve this question
    
Write some more info, system, distro, mysql version permision and owner of actual data directory –  B14D3 Oct 9 '12 at 7:31

1 Answer 1

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

share|improve this answer
    
I don't know how to copy ownership and permission. Can u explain the same please? –  Haseena Oct 9 '12 at 6:15
    
By copy I meant see what ownership has actual data directory (using ls -la) and set up the same on new data directory but its on 100% taht data directory should bed owned by user mysql. Then setup same permisions with chmod on new data directory as actual data direcory has. Sorry my english is not good, I can't write it simpler –  B14D3 Oct 9 '12 at 6:37
    
But shows the same error, after setting the owner and permission of new data dir as same as of actual datadir. –  Haseena Oct 9 '12 at 7:15
    
Show what owner ond permision has actual data directory –  B14D3 Oct 9 '12 at 7:30
1  
>> Why the table not created in the location '/home/test/Sample' ??? CMIIW because the user directory usually set 700. so no matter you change permissions on /home/test/*, the parent permission is still 700 unless you change chmod 755 -R /home/test # useradd testuser # ls -alh /home/ drwx------ 3 testuser testuser 4.0K Oct 9 09:00 testuser –  chocripple Oct 9 '12 at 9:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.