tags:

views:

73

answers:

1

I'm trying make a copy of a MySQL database on another server. I stop the server, tar up the mysql directory, copy it to the other server and untar it. I set all the permissions to match to the working server, and copied the my.cnf file so everything is the same except for server specific changes.

However, when I try to startup the server, I get the following InnoDB error:

InnoDB: Operating system error number 13 in a file operation.
This error means mysql does not have the access rights to
the directory.
File name /var/lib/mysql/ibdata1
File operation call: 'open'.

The owner/group for all the files is mysql. I even tried changing permissions to a+rw. I can su to the mysql user and access the ibdata1 file using head.

SOLUTION:

The problem was selinux was enabled and preventing the new files from being accessed.

+3  A: 

A silly question, but people forget: you said you checked that all files have the same permissions; still, even though it said so in the message, might you possibly have forgotten to check the permissions on the containing directory?

UPDATE: Two more suggestions:

  1. You might try inserting --console and --log-warnings flags, for lots of debugging output, something like this (on my Mac):

    /usr/libexec/mysqld --console --log-warnings --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --socket=/var/lib/mysql/mysql.sock

  2. If all else fails, you can probably try strace mysqld ... to see what exactly is it failing. The error will be somewhere at the bottom.

UPDATE2: Interesting indeed... I can't see what your OS is. I normally don't use /sbin/service, it's a bit mysterious for me; on a Mac, it's deprecated in favour of launchctl with config file in /System/Library/LaunchDaemons/mysqld.plist, and on most Linux boxes you have /etc/init.d/mysqld. So you could insert strace there.

Or (untested, but manpage suggests it's possible) you could try stracing the service call:

strace -ff -o straces /sbin/service start mysqld

This should produce files straces.pid, one of which should be mysqld's, and hopefully you'll find your error there.

Amadan
good argument cookie for you ! if the directory ownership is changed with out chaging the inner aswell it will fail.
Prix
good point, but I did not forget that part.
Brent Baisley
Then I have some more suggestions which might or might not pan out.
Amadan
interesting. Launching mysqld directly, as mysql user, works. What fails is launching it with /sbin/service mysqld start
Brent Baisley
Updated again...
Amadan
thanks will give it try. /etc/init.d/mysqld produces same behavior as /sbin/service. It's CentOS, but I develop on a Mac, love launchctl.
Brent Baisley
:) Anyway, if you do have the `init.d` script, then you can edit it and make it run `strace -ff -o straces mysqld ...` instead of plain `mysqld ...`. Obviously, if you don't have `strace`, install it first :)
Amadan