Q:

Can't enable binary logging ("index not found")

I have a MySQL 5.5.41 server running on Ubuntu 14.04 that already contains several databases of data, and I would like to enable binary logging.  I want the binary logs to be placed in their own directory, /var/log/mysqld, which did not exist prior.  I created the directory, set its permissions to mysql:root 0755, and added a file to /etc/mysql/conf.d with the following contents:
[mysqld]
log_bin=/var/log/mysqld/mysql-bin.log
expire_logs_days=1
binlog_format=ROW

Unfortunately, running service mysql restart then failed to bring MySQL back up, and the MySQL error logs contain the message:
/usr/sbin/mysqld: File '/var/log/mysqld/mysql-bin.index' not found (Errcode: 2)

What do I have to do to get this to work?

A:

It turns out the problem was caused by apparmor.  I had to add the following two lines to /etc/apparmor.d/usr.sbin.mysqld:
  /var/log/mysqld/ r,
  /var/log/mysqld/* rw,

and then run apparmor_parser -r /etc/apparmor.d/usr.sbin.mysqld before restarting MySQL.

