Ubuntu – thesql doesn’t update due to error in apparmor profile

12.04MySQL

I got a mysql error after the update of it.

This is the log.

(Leyendo la base de datos ... 559752 ficheros o directorios instalados actualmente.)
Desinstalando mysql-server ...
Configurando mysql-server-5.5 (5.5.24-0ubuntu0.12.04.1) ...
Error del analizador AppArmor para /etc/apparmor.d/usr.sbin.mysqld in /etc/apparmor.d/usr.sbin.mysqld en la l?nea 40: syntax error, unexpected TOK_END_OF_RULE, expecting TOK_MODE
start: Job failed to start
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error al procesar mysql-server-5.5 (--configure):
 el subproceso instalado el script post-installation devolvió el código de salida de error 1
No se escribió ningún informe «apport» porque ya se ha alcanzado el valor de «MaxReports»
         Se encontraron errores al procesar:
 mysql-server-5.5
E: Sub-process /usr/bin/dpkg returned an error code (1)
Un paquete no se pudo instalar. Tratando de recuperarlo:
Configurando mysql-server-5.5 (5.5.24-0ubuntu0.12.04.1) ...
Error del analizador AppArmor para /etc/apparmor.d/usr.sbin.mysqld in /etc/apparmor.d/usr.sbin.mysqld en la l?nea 40: syntax error, unexpected TOK_END_OF_RULE, expecting TOK_MODE
start: Job failed to start
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error al procesar mysql-server-5.5 (--configure):
 el subproceso instalado el script post-installation devolvió el código de salida de error 1
Se encontraron errores al procesar:
 mysql-server-5.5

If some one can help. I have try to remove mysql server and it tells me this.

Se encontraron errores al procesar:
mysql-server-5.5
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1

ADDED ENGLISH TRANSLATION TO LOG FILE:

(Reading database ... 559752 files and directories currently installed.)
Removing mysql-server ...
Setting up mysql-server-5.5 (5.5.24-0ubuntu0.12.04.1) ...
AppArmor parser error for /etc/apparmor.d/usr.sbin.mysqld in /etc/apparmor.d/usr.sbin.mysqld in the l? Line 40: syntax error, unexpected TOK_END_OF_RULE, expecting TOK_MODE
start: Job failed to start
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing mysql-server-5.5 (--configure):
  subprocess installed post-installation script returned error exit code 1
Do not write any report "dumbbell" because it has already reached the value of "MaxReports»
          Errors were encountered while processing:
  mysql-server-5.5
E: Sub-process /usr/bin/dpkg Returned an error code (1)
A package failed to install. Trying to recover:
Setting up mysql-server-5.5 (5.5.24-0ubuntu0.12.04.1) ...
AppArmor parser error for /etc/apparmor.d/usr.sbin.mysqld in /etc/apparmor.d/usr.sbin.mysqld in the l? Line 40: syntax error, unexpected TOK_END_OF_RULE, expecting TOK_MODE
start: Job failed to start
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing mysql-server-5.5 (--configure):
  subprocess installed post-installation script returned error exit code 1
Errors were encountered while processing:
  mysql-server-5.5

Best Answer

It seems you have an error in your apparmor profile for mysql. While fixing it, you can disable apparmor profile for mysql and mysql should work:

sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/usr.sbin.mysqld

and restart apparmor with: sudo /etc/init.d/apparmor restart

When you have the mysql apparmor profile fixed, you can remove the symlink and restart apparmor.

UPDATE2:

New steps to remove and reinstall mysql:

sudo apt-get purge mysql-server mysql-client mysql-common mysql-client-5.5 mysql-server-5.5
sudo apt-get autoremove
sudo apt-get autoclean

sudo rm -rf /etc/mysql

sudo apt-get install mysql-server mysql-common mysql-client

(should ask for a new admin password)

Check if it works:

sudo service mysql status

If it doesn't work, check if you have a file /etc/mysql/my.cnf. If not, copy it from the default one and restart mysql:

sudo cp /etc/mysql/my.cnf.dpkg-dist /etc/mysql/my.cnf