Mysql/InnoDB says it doesn't have access rights to create temp tables, but it does For mysql  Ver 14.14 Distrib 5.6.33, for Linux (x86_64) using  EditLine wrapper

in my.cnf:

tmpdir          = /var/mysql_tmpfs


in /etc/apparmor.d/usr.sbin.mysqld:

  /var/mysql_tmpfs/ rw,
  /var/mysql_tmpfs/* rw,


Permissions for folder:

drwxrwxrwt  2 mysql    mysql     4096 Nov 28 19:46 mysql_tmpfs


Which, looks right to me. However, it is failing. Right now, mysql will start. However, when I load certain pages of my application, this is the error message that I see:

2016-11-28 20:23:41 39465 [ERROR] InnoDB: Unable to lock /var/mysql_tmpfs/#sql9a29_2_0.ibd, error: 13
2016-11-28 20:23:41 39465 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
2016-11-28 20:23:41 7fd2105d3700  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.
2016-11-28 20:23:41 39465 [ERROR] InnoDB: Cannot create file '/var/mysql_tmpfs/#sql9a29_2_0.ibd'


However, I do not believe there is another process running. When I do a ps aux | grep mysqld, I get this:

mysql    38943  0.0  0.0   4396   736 pts/4    S    20:21   0:00 /bin/sh /usr/bin/mysqld_safe
mysql    39465 10.0  4.0 73330944 5301532 pts/4 Sl  20:21   0:16 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock --port=3306


In addition, I was able to create a file in that directory as the mysql user, which is why I'm extra sure that the user should have the required permissions.

I'm guessing this is something that I'm missing, but I've now had three other people take a look and we have not gotten anywhere. Please help.
Found a solution:

Apparently we needed to use k to give lock file permission. So now usr.sbin.mysqld looks like this:

  /var/mysql_tmpfs/ r,
  /var/mysql_tmpfs/** rwk,


We found the answer on the oracle blog: https://blogs.oracle.com/jsmyth/entry/apparmor_and_mysql