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.

I've installed Ubuntu 10.10 on virtualbox machine. With apache/php/mysql ... now I'm trying to move mysql datadir to folder shared by host os (win7)

so I've done following: 1) mounted shared folder: sudo mount -t vboxsf -o uid=103,gid=110 mysql_h /mnt/db uid,gid of mysql; 2) changed /etc/mysql/my.cnf so datadir will look like: datadir = /mnt/db; 3) restarted service.

while trying to connect to mysql, I get following error: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

PS

user            = mysql
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /mnt/db
tmpdir          = /tmp

UPDATE

I've changed the sharing mode from virtualbox to samba, and mount it using: mount -t smbfs -o username=David,password=,uid=103,gid=110,rw //DAVID-PC/mysql /mnt/db. It mounts okay, with mysql user/group as owners. But I still can't start mysql. error log:

110121 13:24:38 [Note] Plugin 'FEDERATED' is disabled.
/usr/sbin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
110121 13:24:38 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
110121 13:24:38  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.

UPDATE2

grep mysql /etc/passwd
mysql:x:103:110:MySQL Server,,,:/nonexistent:/bin/false

ls -al /mnt/db/ib*
-rwxr-xr-x 1 mysql mysql 10485760 2011-01-21 13:45 /mnt/db/ibdata1
-rwxr-xr-x 1 mysql mysql  5242880 2011-01-21 13:45 /mnt/db/ib_logfile0
-rwxr-xr-x 1 mysql mysql  5242880 2011-01-21 13:45 /mnt/db/ib_logfile1

UPDATE3a

drwxr-xr-x 1 mysql mysql    4096 2011-01-21 23:08 .
drwxr-xr-x 4 root  root     4096 2011-01-20 23:19 ..
-rwxr-xr-x 1 mysql mysql        4 2011-01-21 20:46 apache-server.pid
-rwxr-xr-x 1 mysql mysql        0 2011-01-21 16:21 debian-5.1.flag
-rwxr-xr-x 1 mysql mysql 10485760 2011-01-21 16:42 ibdata1
-rwxr-xr-x 1 mysql mysql  5242880 2011-01-21 23:12 ib_logfile0
-rwxr-xr-x 1 mysql mysql  5242880 2011-01-21 23:13 ib_logfile1
drwxr-xr-x 1 mysql mysql    20480 2011-01-21 16:21 mysql
-rwxr-xr-x 1 mysql mysql        6 2011-01-11 20:32 mysql_upgrade_info

UPDATE4

mysql@apache-server:/$ ls -la /mnt/db/mysql
total 970
drwxr-xr-x 1 mysql mysql  20480 2011-01-24 07:54 .
drwxr-xr-x 1 mysql mysql   4096 2011-01-24 07:54 ..
-rwxr-xr-x 0 mysql mysql   8820 2011-01-24 07:54 columns_priv.frm
-rwxr-xr-x 0 mysql mysql      0 2011-01-24 07:54 columns_priv.MYD
-rwxr-xr-x 0 mysql mysql   4096 2011-01-24 07:54 columns_priv.MYI
-rwxr-xr-x 0 mysql mysql   9582 2011-01-24 07:54 db.frm
-rwxr-xr-x 0 mysql mysql      0 2011-01-24 07:54 db.MYD
-rwxr-xr-x 0 mysql mysql   2048 2011-01-24 07:54 db.MYI
-rwxr-xr-x 0 mysql mysql  10223 2011-01-24 07:54 event.frm
-rwxr-xr-x 0 mysql mysql      0 2011-01-24 07:54 event.MYD
-rwxr-xr-x 0 mysql mysql   2048 2011-01-24 07:54 event.MYI
-rwxr-xr-x 0 mysql mysql   8665 2011-01-24 07:54 func.frm
-rwxr-xr-x 0 mysql mysql      0 2011-01-24 07:54 func.MYD
-rwxr-xr-x 0 mysql mysql   1024 2011-01-24 07:54 func.MYI
-rwxr-xr-x 0 mysql mysql     35 2011-01-24 07:54 general_log.CSM
-rwxr-xr-x 0 mysql mysql      0 2011-01-24 07:54 general_log.CSV
-rwxr-xr-x 0 mysql mysql   8776 2011-01-24 07:54 general_log.frm
-rwxr-xr-x 0 mysql mysql   8700 2011-01-24 07:54 help_category.frm
-rwxr-xr-x 0 mysql mysql  22078 2011-01-24 07:54 help_category.MYD
-rwxr-xr-x 0 mysql mysql   3072 2011-01-24 07:54 help_category.MYI
-rwxr-xr-x 0 mysql mysql   8612 2011-01-24 07:54 help_keyword.frm
-rwxr-xr-x 0 mysql mysql  89044 2011-01-24 07:54 help_keyword.MYD
-rwxr-xr-x 0 mysql mysql  16384 2011-01-24 07:54 help_keyword.MYI
-rwxr-xr-x 0 mysql mysql   8630 2011-01-24 07:54 help_relation.frm
-rwxr-xr-x 0 mysql mysql   8937 2011-01-24 07:54 help_relation.MYD
-rwxr-xr-x 0 mysql mysql  17408 2011-01-24 07:54 help_relation.MYI
-rwxr-xr-x 0 mysql mysql   8770 2011-01-24 07:54 help_topic.frm
-rwxr-xr-x 0 mysql mysql 425616 2011-01-24 07:54 help_topic.MYD
-rwxr-xr-x 0 mysql mysql  20480 2011-01-24 07:54 help_topic.MYI
-rwxr-xr-x 0 mysql mysql   9510 2011-01-24 07:54 host.frm
-rwxr-xr-x 0 mysql mysql      0 2011-01-24 07:54 host.MYD
-rwxr-xr-x 0 mysql mysql   2048 2011-01-24 07:54 host.MYI
-rwxr-xr-x 0 mysql mysql   8778 2011-01-24 07:54 ndb_binlog_index.frm
-rwxr-xr-x 0 mysql mysql      0 2011-01-24 07:54 ndb_binlog_index.MYD
-rwxr-xr-x 0 mysql mysql   1024 2011-01-24 07:54 ndb_binlog_index.MYI
-rwxr-xr-x 0 mysql mysql   8586 2011-01-24 07:54 plugin.frm
-rwxr-xr-x 0 mysql mysql      0 2011-01-24 07:54 plugin.MYD
-rwxr-xr-x 0 mysql mysql   1024 2011-01-24 07:54 plugin.MYI
-rwxr-xr-x 0 mysql mysql   9996 2011-01-24 07:54 proc.frm
-rwxr-xr-x 0 mysql mysql      0 2011-01-24 07:54 proc.MYD
-rwxr-xr-x 0 mysql mysql   2048 2011-01-24 07:54 proc.MYI
-rwxr-xr-x 0 mysql mysql   8875 2011-01-24 07:54 procs_priv.frm
-rwxr-xr-x 0 mysql mysql      0 2011-01-24 07:54 procs_priv.MYD
-rwxr-xr-x 0 mysql mysql   4096 2011-01-24 07:54 procs_priv.MYI
-rwxr-xr-x 0 mysql mysql   8838 2011-01-24 07:54 servers.frm
-rwxr-xr-x 0 mysql mysql      0 2011-01-24 07:54 servers.MYD
-rwxr-xr-x 0 mysql mysql   1024 2011-01-24 07:54 servers.MYI
-rwxr-xr-x 0 mysql mysql     35 2011-01-24 07:54 slow_log.CSM
-rwxr-xr-x 0 mysql mysql      0 2011-01-24 07:54 slow_log.CSV
-rwxr-xr-x 0 mysql mysql   8976 2011-01-24 07:54 slow_log.frm
-rwxr-xr-x 0 mysql mysql   8955 2011-01-24 07:54 tables_priv.frm
-rwxr-xr-x 0 mysql mysql      0 2011-01-24 07:54 tables_priv.MYD
-rwxr-xr-x 0 mysql mysql   4096 2011-01-24 07:54 tables_priv.MYI
-rwxr-xr-x 0 mysql mysql   8636 2011-01-24 07:54 time_zone.frm
-rwxr-xr-x 0 mysql mysql   8624 2011-01-24 07:54 time_zone_leap_second.frm
-rwxr-xr-x 0 mysql mysql      0 2011-01-24 07:54 time_zone_leap_second.MYD
-rwxr-xr-x 0 mysql mysql   1024 2011-01-24 07:54 time_zone_leap_second.MYI
-rwxr-xr-x 0 mysql mysql      0 2011-01-24 07:54 time_zone.MYD
-rwxr-xr-x 0 mysql mysql   1024 2011-01-24 07:54 time_zone.MYI
-rwxr-xr-x 0 mysql mysql   8606 2011-01-24 07:54 time_zone_name.frm
-rwxr-xr-x 0 mysql mysql      0 2011-01-24 07:54 time_zone_name.MYD
-rwxr-xr-x 0 mysql mysql   1024 2011-01-24 07:54 time_zone_name.MYI
-rwxr-xr-x 0 mysql mysql   8686 2011-01-24 07:54 time_zone_transition.frm
-rwxr-xr-x 0 mysql mysql      0 2011-01-24 07:54 time_zone_transition.MYD
-rwxr-xr-x 0 mysql mysql   1024 2011-01-24 07:54 time_zone_transition.MYI
-rwxr-xr-x 0 mysql mysql   8748 2011-01-24 07:54 time_zone_transition_type.frm
-rwxr-xr-x 0 mysql mysql      0 2011-01-24 07:54 time_zone_transition_type.MYD
-rwxr-xr-x 0 mysql mysql   1024 2011-01-24 07:54 time_zone_transition_type.MYI
-rwxr-xr-x 0 mysql mysql  10466 2011-01-24 07:54 user.frm
-rwxr-xr-x 0 mysql mysql    468 2011-01-24 07:54 user.MYD
-rwxr-xr-x 0 mysql mysql   2048 2011-01-24 07:54 user.MYI

mysql@apache-server:/$ sum /mnt/db/ibdata1
02939 10240

mysql@apache-server:/$ cat /mnt/db/small.txt
very small text file from windows

mysql@apache-server:/$ ls -la /mnt/db/small.txt
-rwxr-xr-x 1 mysql mysql 33 2011-01-24 07:59 /mnt/db/small.txt

mysql@apache-server:/$ ls -la /mnt/db/mysql > /mnt/db/small
mysql@apache-server:/$ ls -la /mnt/db
total 20517
drwxr-xr-x 1 mysql mysql     4096 2011-01-24 08:03 .
drwxr-xr-x 4 root  root      4096 2011-01-20 23:19 ..
-rwxr-xr-x 1 mysql mysql        0 2011-01-24 07:54 debian-5.1.flag
-rwxr-xr-x 1 mysql mysql 10485760 2011-01-24 07:54 ibdata1
-rwxr-xr-x 1 mysql mysql  5242880 2011-01-24 07:54 ib_logfile0
-rwxr-xr-x 1 mysql mysql  5242880 2011-01-24 07:54 ib_logfile1
drwxr-xr-x 1 mysql mysql    20480 2011-01-24 07:54 mysql
-rwxr-xr-x 1 mysql mysql        6 2011-01-24 07:54 mysql_upgrade_info
-rwxr-xr-x 1 mysql mysql     4562 2011-01-24 08:03 small
share|improve this question

closed as off-topic by Falcon Momot, Michael Hampton Aug 4 '13 at 6:28

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must be relevant to professional system administration. Server Fault is a site dedicated to professionals; novice questions are off-topic. Please see the Help Center for more information on topicality. The best advice we can give you is to hire a professional to help you out." – Falcon Momot, Michael Hampton
If this question can be reworded to fit the rules in the help center, please edit the question.

    
The error message suggests that mysqld failed to start. You need to check your logs to see why not. –  John Gardeniers Jan 21 '11 at 0:08
    
checked the logs... I don't know what's the problem // tried to run upgrade –  David Jan 21 '11 at 11:33
    
Can we see the outputs of grep mysql /etc/passwd and ls -al /mnt/db/ibdata1 ? –  MadHatter Jan 21 '11 at 12:15
    
...just added :) –  David Jan 21 '11 at 14:28
    
Mm. As user mysql, could you do touch /mnt/db/ibNOTAREALFILE, ls -al /mnt/db/, rm /mnt/db/ibNOTAREALFILE, sum /mnt/db/ibdata1, and touch /mnt/db/ibdata1, and let us see the outputs? Since you were kind enough to let me know all the files that matched /mnt/db/ib*, I'm pretty sure the ibNOTALREALFILE thing above won't harm anything permanently. I suspect that mysql isn't able to open everything it wants to, and the above should help test that. –  MadHatter Jan 21 '11 at 15:28
show 6 more comments

3 Answers

The error can't be any more clear. It is a permissions issue. You are able to read/write the folder as your own user but what about the user mysql. Mysqld runs with permissions of user mysql therefore you need to make sure that user "mysql" can read and write to your data director.

Snippet of your log
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.

share|improve this answer
    
as I commented above, mysql is set to be the owner of that folder. Specifically this part: uid=103,gid=110,rw. may be I'm setting it wrong as group doesn't have write permissions –  David Jan 21 '11 at 14:30
add comment
up vote 1 down vote accepted

In the end it was one another conf. file with datadir location. After fixing it - everything worked.

/etc/apparmor.d/usr.sbin.mysqld

share|improve this answer
    
Ah yes! Apparmor was caused me troubles before when moving the datadir to new locations. –  Coops Feb 16 '11 at 12:08
add comment

David:

firstly, thanks for running all those tests above. I'm glad that touch/rm as mysql worked without sudo, because that's what we were testing. I agree with the others that the signs all point to a permissions problem, but I can see nearly no signs of one.

As a passing test, could I also get the output from ls -la /mnt/db/mysql ?

The only oddity in the data you've supplied is the output from sum /mnt/db/ibdata1, which used to be above but seems to have vanished, and if I recall correctly was something like

00000  320

That's odd because usually only a file full of zeros will give output like that. It's possible for it to happen randomly, but there's only a one-in-a-hundred-thousand chance. My gut feeling is that even a freshly-made mysql datafile shouldn't be totally empty.

Is it possible that somehow you're being allowed to list the directory, open files, etc., but the backend server is giving you only zeroes when the contents of a file are asked for? Could you test this hypothesis by making a small textfile of known contents on the Windows server side, then trying

cat /mnt/db/SmallTextFile

on the Linux side, as user mysql? A similar test where the file is both created and read on the Linux side (as user mysql in both cases) would be helpful, too. I can't think of any other way to confirm that the file system will give back data that are put into it.

If that isn't it I'm rather out of ideas, sorry. I'm glad you felt you were learning new stuff while we ran all these tests, though!

share|improve this answer
    
thanks a lot. See Update4. note r-x permissions for group, maybe it have something to do with problem. These files are copied from regular mysql datadir, and there they had another permissions, which I didn't change. -rw-rw---- 1 mysql mysql 8820 2011-01-11 20:32 columns_priv.frm. So I'm guessing that permissions are being set automatically by Samba. –  David Jan 24 '11 at 6:12
    
Since the mysql database ought to run as the mysql user, the group permissions shouldn't matter. One last lunatic fringe question: you are starting mysql as the root user, using the normal system startup scripts, aren't you? –  MadHatter Jan 24 '11 at 12:10
    
yes. and I tried to stop service and restart it to several times. In the end it will be something stupid that we forgot to think about. :) –  David Jan 24 '11 at 15:50
    
<grin> that's my fear, too. when you say you started and stopped it, you mean something like sudo /etc/init.d/mysqld start, yes? –  MadHatter Jan 24 '11 at 18:23
    
more like sudo services mysql stop or start –  David Jan 26 '11 at 21:20
show 2 more comments

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