由于 apparmor 配置文件错误,mysql 无法更新

由于 apparmor 配置文件错误,mysql 无法更新

更新后我收到 mysql 错误。

这是日志。

(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

如果有人能帮忙。我尝试删除 mysql 服务器,它告诉我这个。

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

在日志文件中添加英文翻译:

(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

答案1

看来您的 mysql apparmor 配置文件中存在错误。修复此问题时,您可以禁用 mysql 的 apparmor 配置文件,这样 mysql 就可以正常工作了:

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

并使用以下命令重新启动 apparmor:sudo /etc/init.d/apparmor restart

当您修复了 mysql apparmor 配置文件后,您可以删除符号链接并重新启动 apparmor。

更新2:

删除并重新安装 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

(应要求输入新的管理员密码)

检查是否有效:

sudo service mysql status

如果不起作用,请检查是否有文件/etc/mysql/my.cnf。如果没有,请从默认文件复制并重新启动mysql:

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

答案2

我认为这与以下问题有关: https://bugs.launchpad.net/ubuntu/+source/mysql-dfsg-5.1/+bug/375371 https://bugs.launchpad.net/ubuntu/+source/mysql-dfsg-5.0/+bug/227615

我必须改变 mysql 正在使用的 tmp 目录的位置:

编辑 /etc/mysql/my.cnf

改变:

tmpdir      = /tmp

到:

tmpdir      = /var/tmp/mysql

并确保您创建该目录并适当地设置权限:

sudo mkdir -m 0770 /var/tmp/mysql
sudo chown mysql:mysql /var/tmp/mysql

然后您可以尝试重新安装,它应该可以工作(对我来说很好):

sudo apt-get install -f

相关内容