2

I've moved all the stuff in /var/lib/mysql to /500gb/mysql, and created a symbolic link from one to the other. I then did a chown mysql:mysql and chmod 777 (with both -h and -R as necessary) to both the /var/lib/mysql symbolic link, and also /500gb/mysql.

ls -al /var/lib gives me:

lrwxrwxrwx  1 mysql         mysql         15 2011-07-27 12:55 mysql -> /500gb/mysql

When I try to start MySQL (service mysql start), I get the following in /var/log/mysql/error.log:

110727 12:48:32 [Note] Plugin 'FEDERATED' is disabled.
/usr/sbin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
110727 12:48:32 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
110727 12:48:32  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.

Both /500gb/mysql/ibdata1 and /500gb/mysql/mysql/plugin.frm exist and are owned by mysql. What's the deal?

Also, MySQL seems to occasionally clobber my symbolic link. It disappears and becomes a regular directory after a number of failed starts.

I've also tried editing my /etc/mysql/my.cnf and setting datadir = /500gb/mysql with no luck.

Any ideas? Thanks.

Mike Cialowicz
  • 283
  • 1
  • 3
  • 10
  • I saw the "_[ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it._" message. Have you updated MySQL version recently? – quanta Jul 28 '11 at 02:36

2 Answers2

3

It turns out that Apparmor was screwing things up. We had to edit this file: /etc/apparmor.d/usr.sbin.mysql.

Mike Cialowicz
  • 283
  • 1
  • 3
  • 10
  • 1
    Important Note:-From Ubuntu 7.10 (Gutsy Gibbon) forward, Ubuntu uses some security software called AppArmor that specifies the areas of your filesystem applications are allowed to access. Unless you modify the AppArmor profile for MySQL, you'll never be able to restart MySQL with the new datadir location. – lg. Jan 09 '13 at 09:14
0

Many UNIX daemons will refuse to work with files having access permissions which are too lenient (too many people have read/write access to them). Try running:

find /500gb/mysql -type f -exec chmod a-x {} \;
chmod -R u+rwX,go-rwx /500gb/mysql
chown -Rh mysql:mysql /500gb/mysql

And then start MySQL.

Scott Duckworth
  • 846
  • 1
  • 10
  • 12