4

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
HopelessN00b
  • 53,795
  • 33
  • 135
  • 209
Haseena
  • 151
  • 1
  • 1
  • 5
  • Write some more info, system, distro, mysql version permision and owner of actual data directory – B14D3 Oct 09 '12 at 07:31

1 Answers1

2

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

B14D3
  • 5,188
  • 15
  • 64
  • 83
  • I don't know how to copy ownership and permission. Can u explain the same please? – Haseena Oct 09 '12 at 06: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 09 '12 at 06:37
  • But shows the same error, after setting the owner and permission of new data dir as same as of actual datadir. – Haseena Oct 09 '12 at 07:15
  • Show what owner ond permision has actual data directory – B14D3 Oct 09 '12 at 07:30
  • `drwx------ 4 mysql mysql 4096 2012-10-08 16:16 mysql` - actual data directory. `drwx------ 3 mysql mysql 4096 2012-10-09 12:08 Sample` - new data directory – Haseena Oct 09 '12 at 08:34
  • 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 09 '12 at 09:01