Sunday, July 28, 2013

Moving the MySQL Tmpdir on Ubuntu

One thing I frequently forget when changing the default directories for various services in Ubuntu is that the AppArmor config for those services also needs to be updated. Case in point, the other day I needed to change MySQL's tmpdir to a different disk, and struggled for a while with "Can't create/write to file 'xyz' (Errcode: 13)" errors until I remembered AppArmor. These were the steps I ended up taking:

Create the new tmpdir
mkdir /mnt/foo/tmp && sudo chown mysql:mysql /mnt/foo/tmp
Change /etc/mysql/my.cnf to use the new tmpdir
tmpdir = /mnt/foo/tmp
Add new tmpdir entries to /etc/apparmor.d/local/usr.sbin.mysqld
/mnt/foo/tmp/ r,
/mnt/foo/tmp/** rw,
Reload AppArmor
sudo service apparmor reload
Restart MySQL
sudo service mysql restart

While I was troubleshooting, I found a nice, in-depth blog entry by Jeremy Smyth explaining how to debug issues with AppArmor and MySQL.


  1. dude, that's a 5 stars from me thanks!

  2. Elect for the 705 in case you are in possession of a massive room needing more power than the 605 or if you would like its automated setup features.More information on Biography | Watch Movies Online For Free - Fmovies - click here.

  3. 1 idea that may help you develop an enjoyable party theme is encouraging your guests to opt for a costume that starts with a particular letter of the alphabet. More interesting information on Watch Full ReBoot Free - Putlockers.