0

In my installation of MySQL the database files are located in ./var/lib/mysql. I wanted to move one of those databases to another drive, so I followed instructions to move one database to a different directory and copied the data files for the database to a different drive, made a symlink to that directory with the same name as the original database folder. Chowned both the directory recusively and the symlink to mysql, same as the other directories in ./var/lib/mysql.

When I restarted MySQL, everything ran fine, but the database at issue is missing (Not critical because this is a dry run.) I checked the logs and had these errors:

2018-07-28T02:43:59.449437Z 0 [Warning] InnoDB: Ignoring tablespace `sf_master/tablename` because it could not be opened. 2018-07-28T02:43:59.449465Z 0 [ERROR] InnoDB: The error means the system cannot find the path specified. 2018-07-28T02:43:59.449474Z 0 [ERROR] InnoDB: Cannot open datafile for read-only: './sf_master/tablename.ibd' OS error: 71 

I set selinux to permissive to see if that was the problem but the errors are the same.

I confirmed that in my.cnf that symbolic-links=1 and that on the restart I had innodb_force_recovery = 1

The data folder looks like:

-rw-r-----. 1 mysql mysql 56 Apr 24 2017 auto.cnf drwxr-x---. 2 mysql mysql 4096 Apr 24 2017 mysql drwxr-x---. 2 mysql mysql 4096 Dec 6 2017 operators lrwxrwxrwx. 1 mysql mysql 16 Jul 27 22:33 sf_master -> ./nvme/sf_master drwxr-x---. 2 mysql mysql 8192 Apr 24 2017 sys 

NOTE:

I'm posting this problem on serverfault because I think the problem has to do with my understanding of symlinks and the way they are used on directories in linux file systems, or possibly permissions. I'm running a centos 7 server.

UPDATE:

Per Wilson Hauck's request the corrected directory is:

-rw-r-----. 1 mysql mysql 56 Apr 24 2017 auto.cnf drwxr-x---. 2 mysql mysql 4096 Apr 24 2017 mysql drwxr-x---. 2 mysql mysql 4096 Dec 6 2017 operators lrwxrwxrwx. 1 mysql mysql 16 Jul 27 22:33 sf_master -> /nvme/sf_master drwxr-x---. 2 mysql mysql 8192 Apr 24 2017 sys 

This was really just a very dumb typo error.

1 Answer 1

2

Your symlink is wrong.

In /var/lib/mysql, the symlink sf_master -> ./nvme/sf_master points to /var/lib/mysql/nvme/sf_master. The target of the symlink needs to be a fully-qualified path, not relative to the current directory. The leading . makes it relative.

2
  • 1
    I was issuing the commands from the root folder / so I mistakenly thought it was relative to root, not to where the symlink was. Thank you. Everything is working right now. Commented Jul 28, 2018 at 4:50
  • @AuntJemima Please post the CURRENT data folder content so we can the corrective action you applied for the link to work in your environment. Commented Aug 2, 2019 at 22:34

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.