Mysql replication, error 13 (permission denied) with slave_load_tmpdir I've setup a virtual machine on Azure with Ubuntu 16.10 and Mysql 5.7 for a database replication Master/Slave from another server.

I followed this article: https://www.opsdash.com/blog/mysql-replication-howto.html

All seems to works correctly, replication works but I've serious problems with the use of DATA LOAD INFILE. If I use this command, the replication doesn't works.

I tried with relative varible "slave_load_tmpdir", creating a new directory '/var/slavetmp' and updating my.cnf with these values, but this is the error in mysql with "SHOW SLAVE STATUS":


  Unable to use slave's temporary directory /var/slavetmp - Can't read dir of '/var/slavetmp/' (Errcode: 13 - Permission denied)


Have any ideas?

Thanks in advance
Assuming that the MySQL user is called "mysql" (check for "user" in my.cnf):


chown mysql.mysql -R /var/slavetmp
Edit /etc/apparmor.d/usr.sbin.mysqld.  Copy the lines for /var/lib/mysql and edit the copied lines to refer to /var/slavetmp
Restart AppArmor:  /etc/init.d/apparmor restart
Restart the mysql service