Monday, May 6, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 1545  / 1 Year ago, mon, november 21, 2022, 11:59:09

I have Ubuntu Desktop 11.04 and I'm trying to move /var/lib/mysql to a TrueCrypt volume and am failing at every attempt.



This is for development purposes, and there's a particular database I need to work with that needs to be highly secure for numerous reasons.



Upon a fresh install of mysql-server and mysql-client, I'm able to start mysql without any problem. So I then move /var/lib/mysql to the TrueCrypt volume (call it /foo/truecrypt), and then edit /etc/mysql/my.cnf to point datadir to /foo/truecrypt.



After I check permissions to make sure that they are the same, I try to start mysql again.



It doesn't work (MySQL just continues to hang), and I'm unable to get MySQL to work again (even after killing all mysql processes and moving the datadir back to /var/lib/mysql). I've done a apt-get --purge remove mysql-client mysql-server mysql-common (and then deleted all files in /var/lib/mysql, etc/mysql/ and /var/log/mysql*) at least 5 times tonight in order to get a fresh install to try again.



While MySQL hangs, I've gone into /var/log/mysql/ and here's what shows up in mysql.err:



120421 22:50:03 [Note] Plugin 'FEDERATED' is disabled.
^G/usr/sbin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
120421 22:50:03 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
120421 22:50:03 InnoDB: Initializing buffer pool, size = 8.0M
120421 22:50:03 InnoDB: Completed initialization of buffer pool
120421 22:50:03 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.


I've tried moving /var/lib/mysql/ and then creating a symlink instead of editing my.cnf. That doesn't make a difference. The errors above indicate a missing file or permissions issues. However, plugin.frm exists in /foo/truectrypt/mysql/mysql (as I simply just moved the parent directory), and ownership and permissions on that and all other files in that directory are the same as they were.



Do you have any suggestions? I'm stumped.


More From » mysql

 Answers
3

The issue was with AppArmor, which I've never had experience with. I (finally) found an obscure website that said the following:




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.




(from http://article.my-addr.com/?show=linux_ubuntu_change_datadir-move_mysql_database_to_other_path)



I needed to edit /etc/apparmor.d/usr.sbin.mysqld as follows:



After following the instructions to "Duplicate the lines beginning with /var/lib/mysql and replace duplicated strings with /usr/new_datadir", and then symlinking /usr/new_datadir to /var/lib/mysql, it works like a charm!


[#39168] Wednesday, November 23, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
soahan

Total Points: 230
Total Questions: 123
Total Answers: 123

Location: Maldives
Member since Tue, Dec 21, 2021
2 Years ago
soahan questions
Fri, May 7, 21, 06:17, 3 Years ago
Mon, Jan 16, 23, 05:49, 1 Year ago
Mon, Dec 13, 21, 14:40, 2 Years ago
;