Ubuntu Multiple MySQL instances and Apparmor I am trying to set up multiple instances of MySQL on an Ubuntu dev machine and running into AppArmor problems.

I get this error in the syslogs:

kernel: [227631.776360] type=1400 audit(1329786835.208:146): apparmor="DENIED" 
    operation="mknod" parent=7957 profile="/usr/sbin/mysqld" 
    name="/run/mysqld/mysqld-5-5-20.sock" pid=8066 comm="mysqld" 
    requested_mask="c" denied_mask="c" fsuid=114 ouid=114

mysqld_safe: mysqld from pid 
    file /usr/local/mysql-5.5.20/data/naveen-desktop-ubuntu.pid ended 


I checked threads here that suggest to use mysql_multi - but I do not know if mysql_multi allows instances of servers with different versions to be run. 

I already have mysql-5.1 running and want to install mysql-5.5. 

I know there has to be something wrong the way I have configured AppArmor - but no help from Google!

Here are details and what I have done so far:


OS : Ubuntu 11.10 desktop 32 bit
MySQL installed: default Ubuntu package 5.1.58-1ubuntu1 
Trying to install: mysql-server 5.5.20
running all commands as root


To keep most of the new installation files separately into a single folder (/usr/local/mysql-5.5.50) I created 4 new directories under the main mysql-5.5.50


source: downloaded and unzipped MySQL files
data : to hold data (owned by MySQL)
log : for all log files 
tmp : for tmp files


user=mysql has write access to the entire top folder mysql-5.5.50
created new my.cnf file in the same dir with these details: 

[client]
port        = 3307
socket      = /var/run/mysqld/mysqld-5-5-20.sock

[mysqld_safe]
socket      = /var/run/mysqld/mysqld-5-5-20.sock
nice        = 0

[mysqld]
user        = mysql
socket      = /var/run/mysqld/mysqld-5-5-20.sock
port        = 3307
basedir     = /usr
datadir     = /usr/local/mysql-5.5.20/data
tmpdir      = /usr/local/mysql-5.5.20/tmp

log_error   = /usr/local/mysql-5.5.20/log/error.log


AppArmor details:

/etc/apparmor.d/usr.sbin.mysqld has the line #include  at the end.

I added below lines to local/usr.sbin.mysqld:

/usr/local/mysql-5.5.20/* r,    
/usr/local/mysql-5.5.20/** rwk,
/{,var/}run/mysqld/mysql-5.5.20.pid w,
/{,var/}run/mysqld/mysql-5.5.20.sock w,


I've restarted AppArmor with /etc/init.d/apparmor restart.

MySQL install:

mysql_install_db --user=mysql --datadir=/usr/local/mysql-5.5.20/data/


This command completed with PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! and I can see that /data now has files.

Start MySQL 

/usr/bin/mysqld_safe --defaults-file=/usr/local/mysql-5.5.20/my.cnf 


Now I get the error in the syslog.

What am i doing wrong?
I ran into apparmor headaches getting multiple instances going on ubuntu myself.  Your configs look legit but I'm not super familiar w/ apparmor to spot a subtle problem if one lied there.  In my case I was just running multiple copies of the same binaries w/ different cnfs

Your initial error cited

name="/run/mysqld/mysqld-5-5-20.sock"


It seems maybe there's a config option that didn't come through in what you pasted that's looking to work with /run (instead of /var/run) ?