{"id":1211,"date":"2012-08-20T14:46:58","date_gmt":"2012-08-20T14:46:58","guid":{"rendered":"http:\/\/blog.designed79.co.uk\/?p=1211"},"modified":"2012-08-20T15:07:49","modified_gmt":"2012-08-20T15:07:49","slug":"apparmor-locking-mysql-moved-data-folder","status":"publish","type":"post","link":"https:\/\/blog.designed79.co.uk\/?p=1211","title":{"rendered":"AppArmor Locking MySql moved data folder in Ubuntu"},"content":{"rendered":"<p>I found that AppArmor was the culprit by examining the syslog, and was able to successfully change the mysql data location by following this process.<\/p>\n<p>&nbsp;<\/p>\n<p>Please note that, in files edited below, lines starting with + were added, and lines starting with &#8211; were removed. You should not actually type\/paste the + signs when adding lines to these files.<\/p>\n<p>&nbsp;<\/p>\n<p>I cloned the mysql directory to the new location:<\/p>\n<p>&nbsp;<\/p>\n<p>sudo rsync -av \/var\/lib\/mysql \/new_dir<\/p>\n<p>Then I edited the datadir line in \/etc\/mysql\/my.cnf:<\/p>\n<p>&nbsp;<\/p>\n<p>sudo vi \/etc\/mysql\/my.cnf<\/p>\n<p>-datadir = \/var\/lib\/mysql<\/p>\n<p>+datadir = \/new_dir\/mysql<\/p>\n<p>Then I edited \/etc\/apparmor.d\/usr.sbin.mysqld:<\/p>\n<p>&nbsp;<\/p>\n<p>sudo vi \/etc\/apparmor.d\/usr.sbin.mysqld<\/p>\n<p>&#8211; \/var\/lib\/mysql\/ r,<\/p>\n<p>&#8211; \/var\/lib\/mysql\/** rwk,<\/p>\n<p>+ \/new_dir\/mysql\/ r,<\/p>\n<p>+ \/new_dir\/mysql\/** rwk,<\/p>\n<p>Then I restarted mysql.<\/p>\n<p>&nbsp;<\/p>\n<p>More info here<\/p>\n<p><a href=\"https:\/\/help.ubuntu.com\/community\/AppArmor\">https:\/\/help.ubuntu.com\/community\/AppArmor<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I found that AppArmor was the culprit by examining the syslog, and was able to successfully change the mysql data location by [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[10,20],"class_list":["post-1211","post","type-post","status-publish","format-standard","hentry","category-info-on-tech","tag-server","tag-ubuntu"],"_links":{"self":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1211","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1211"}],"version-history":[{"count":0,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1211\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}