I've mounted a separate hdd to /mnt/temp, and changed datadir to point to this. I added the correct settings in apparmor and worked away with mysql for a few hours. After adding performance_schema to my.cnf and attempting to restart mysql, I am getting the errors:

[Warning] Can't create test file /mnt/temp/some_dir/blah.lower-test
[ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable

I've since chmod -R 777 /mnt/temp, shut down app armor, remounted the partition, manually killed any processes that would be interacting with the partition, and removed performance_schema from my configuration.

Any suggestions?


From Learning MySQL: AppArmor and MySQL

If you want to relocate the data directory in MySQL (in this example, to the /data/directory), and AppArmor is not letting you, add the following two lines to the bottom of /etc/apparmor.d/local/usr.sbin.mysqld:

/data/ r,
/data/** rwk, 

...and then reload the AppArmor profiles:

sudo service apparmor reload 
| improve this answer | |
  • this worked for me as i have the mysql data in /mnt/data/mysql – Andres Leon Rangel Nov 24 '19 at 20:59
  • after looking for hours and trying so many things, this is the solution that worked for me. Thanks – Dr. DS Mar 23 at 12:47

I encountered the same, and could figure it was an issue with ownership (this also gave me the illusion of an issue with AppArmor).

May be you can try this (change /var/lib/mysql if it’s not matching yours):

sudo chown -R mysql /var/lib/mysql
sudo chgrp -R mysql /var/lib/mysql

As an explanatory side note, the user and group IDs for MySQL changed since older Ubuntu release. The previous user ID and group ID was now looking as hplip and pulse-access. Since the data directory is a mount‑bind for me (on another partition), it still had these previous IDs whose assignation changed.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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