如何处理由于其初始化脚本行为不当而导致软件包无法正确配置?

如何处理由于其初始化脚本行为不当而导致软件包无法正确配置?

我安装了 mysql 5.5,据我所知,它运行正常,但每次运行时,aptitude install someProgram它都会尝试完成安装,并要求我设置一个新的 mysql 密码,但仍然失败。

我不想卸载它,因为它可以工作,而且我已经尝试重新安装它,但每次都会发生同样的问题。

是否可以将软件包标记为已安装,以便每次安装某些东西时,aptitude 不再花一分钟尝试配置 mysql(并且失败)?

编辑:这是 aptitude 的输出,但下面有更新的版本

root@server:~# aptitude install fping
The following NEW packages will be installed:
  fping
The following partially installed packages will be configured:
  mysql-server mysql-server-5.5
0 packages upgraded, 1 newly installed, 0 to remove and 29 not upgraded.
Need to get 35.0 kB of archives. After unpacking 114 kB will be used.
Get: 1 http://http.debian.net/debian/ wheezy/main fping armhf 3.2-1 [35.0 kB]
Fetched 35.0 kB in 0s (86.4 kB/s)
Selecting previously unselected package fping.
(Reading database ... 29917 files and directories currently installed.)
Unpacking fping (from .../archives/fping_3.2-1_armhf.deb) ...
Processing triggers for man-db ...
Setting up mysql-server-5.5 (5.5.31+dfsg-0+wheezy1) ...
[ ok ] Stopping MySQL database server: mysqld.
[ ok ] Starting MySQL database server: mysqld . ..
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing mysql-server-5.5 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.5; however:
  Package mysql-server-5.5 is not configured yet.

dpkg: error processing mysql-server (--configure):
 dependency problems - leaving unconfigured
Setting up fping (3.2-1) ...
Errors were encountered while processing:
 mysql-server-5.5
 mysql-server
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.31+dfsg-0+wheezy1) ...
[ ok ] Stopping MySQL database server: mysqld.
130711 11:36:34 [ERROR] An old style --language value with language specific part detected: /usr/share/mysql/english/
130711 11:36:34 [ERROR] Use --lc-messages-dir without language specific part instead.
130711 11:36:34 [Note] Plugin 'FEDERATED' is disabled.
130711 11:36:34 InnoDB: The InnoDB memory heap is disabled
130711 11:36:34 InnoDB: Mutexes and rw_locks use GCC atomic builtins
130711 11:36:34 InnoDB: Compressed tables use zlib 1.2.7
130711 11:36:34 InnoDB: Using Linux native AIO
130711 11:36:34 InnoDB: Initializing buffer pool, size = 128.0M
130711 11:36:35 InnoDB: Completed initialization of buffer pool
130711 11:36:35 InnoDB: highest supported file format is Barracuda.
130711 11:36:36  InnoDB: Waiting for the background threads to start
130711 11:36:37 InnoDB: 5.5.31 started; log sequence number 1595695
130711 11:36:37  InnoDB: Starting shutdown...
130711 11:36:38  InnoDB: Shutdown completed; log sequence number 1595695
[ ok ] Starting MySQL database server: mysqld . ..
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing mysql-server-5.5 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.5; however:
  Package mysql-server-5.5 is not configured yet.

dpkg: error processing mysql-server (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 mysql-server-5.5
 mysql-server

编辑2:这是 kostix 更改之后的新 aptitude 输出:

root@server:~# grep -rFw language /etc/mysql/
/etc/mysql/my.cnf:language        = /usr/share/mysql/english
root@server:~# nano /etc/mysql/my.cnf
root@server:~# aptitude install
The following partially installed packages will be configured:
  mysql-server mysql-server-5.5
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 30 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.
Setting up mysql-server-5.5 (5.5.31+dfsg-0+wheezy1) ...
[ ok ] Stopping MySQL database server: mysqld.
[ ok ] Starting MySQL database server: mysqld ..
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing mysql-server-5.5 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.5; however:
  Package mysql-server-5.5 is not configured yet.

dpkg: error processing mysql-server (--configure):
 dependency problems - leaving unconfigured
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.31+dfsg-0+wheezy1) ...
[ ok ] Stopping MySQL database server: mysqld.
130711 13:10:35 [Note] Plugin 'FEDERATED' is disabled.
130711 13:10:35 InnoDB: The InnoDB memory heap is disabled
130711 13:10:35 InnoDB: Mutexes and rw_locks use GCC atomic builtins
130711 13:10:35 InnoDB: Compressed tables use zlib 1.2.7
130711 13:10:35 InnoDB: Using Linux native AIO
130711 13:10:35 InnoDB: Initializing buffer pool, size = 128.0M
130711 13:10:35 InnoDB: Completed initialization of buffer pool
130711 13:10:35 InnoDB: highest supported file format is Barracuda.
130711 13:10:35  InnoDB: Waiting for the background threads to start
130711 13:10:36 InnoDB: 5.5.31 started; log sequence number 1595695
130711 13:10:36  InnoDB: Starting shutdown...
130711 13:10:37  InnoDB: Shutdown completed; log sequence number 1595695
[ ok ] Starting MySQL database server: mysqld ..
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing mysql-server-5.5 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.5; however:
  Package mysql-server-5.5 is not configured yet.

dpkg: error processing mysql-server (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 mysql-server-5.5
 mysql-server

编辑3:使用设置 -u -e -x 标志:

root@server:~# aptitude install screen
The following NEW packages will be installed:
  screen 
The following partially installed packages will be configured:
  mysql-server mysql-server-5.5 
0 packages upgraded, 1 newly installed, 0 to remove and 30 not upgraded.
Need to get 633 kB of archives. After unpacking 824 kB will be used.
Get: 1 http://http.debian.net/debian/ wheezy/main screen armhf 4.1.0~20120320gitdb59704-7 [633 kB]
Fetched 633 kB in 1s (443 kB/s) 
Selecting previously unselected package screen.
(Reading database ... 29927 files and directories currently installed.)
Unpacking screen (from .../screen_4.1.0~20120320gitdb59704-7_armhf.deb) ...
Processing triggers for install-info ...
Processing triggers for man-db ...
Setting up mysql-server-5.5 (5.5.31+dfsg-0+wheezy1) ...
Stopping MySQL database server: mysqld.
Starting MySQL database server: mysqld ..
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing mysql-server-5.5 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.5; however:
  Package mysql-server-5.5 is not configured yet.

dpkg: error processing mysql-server (--configure):
 dependency problems - leaving unconfigured
Setting up screen (4.1.0~20120320gitdb59704-7) ...
Errors were encountered while processing:
 mysql-server-5.5
 mysql-server
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.31+dfsg-0+wheezy1) ...
Stopping MySQL database server: mysqld.
130711 16:39:19 [Note] Plugin 'FEDERATED' is disabled.
130711 16:39:19 InnoDB: The InnoDB memory heap is disabled
130711 16:39:19 InnoDB: Mutexes and rw_locks use GCC atomic builtins
130711 16:39:19 InnoDB: Compressed tables use zlib 1.2.7
130711 16:39:19 InnoDB: Using Linux native AIO
130711 16:39:19 InnoDB: Initializing buffer pool, size = 128.0M
130711 16:39:19 InnoDB: Completed initialization of buffer pool
130711 16:39:19 InnoDB: highest supported file format is Barracuda.
130711 16:39:19  InnoDB: Waiting for the background threads to start
130711 16:39:20 InnoDB: 5.5.31 started; log sequence number 1595695
130711 16:39:21  InnoDB: Starting shutdown...
130711 16:39:22  InnoDB: Shutdown completed; log sequence number 1595695
Starting MySQL database server: mysqld ..
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing mysql-server-5.5 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.5; however:
  Package mysql-server-5.5 is not configured yet.

dpkg: error processing mysql-server (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 mysql-server-5.5
 mysql-server

答案1

第一个问题(MySQL 错误)

关于这些[ERROR]内容……

请这样做

# grep -rFw language /etc/mysql/

正如我所料,您的配置文件仍然引用了已弃用的配置选项。

例如,在我的一个从 Squeeze 升级而来的 Wheezy 系统上,我有:

# grep -rFw language /etc/mysql
/etc/mysql/my.cnf.dpkg-old:language     = /usr/share/mysql/english
# grep -rFw lc-messages-dir /etc/mysql
/etc/mysql/my.cnf:lc-messages-dir       = /usr/share/mysql

请注意,旧指令位于.dpkg-old文件中(未使用),并且lc-messages-dir位于“活动”文件中。

在活动配置文件中注释掉该选项应该可以为您解决这个问题。请注意,MySQL 还会从目录中language加载所有与模式匹配的文件。*.cnf/etc/mysql/conf.d

第二个问题(MySQL守护进程启动失败)

解决这个问题的快速方法:/etc/init.d/mysql在文本编辑器中打开 rc-file,找到脚本参数上的 case switch 调度,并将其放在exit 0处理启动参数的分支中的第一个命令之前;然后运行dpkg --configure --pending。在它(据称)成功之后,恢复您的编辑。

这个技巧背后的想法是让 rc 脚本的启动目标成功完成。当软件包的安装后脚本(postinstDebian 开发人员的术语为脚本)出现问题时,同样的方法有时也可用于卸载软件包 — 将其放置exit 0在脚本开头附近/var/lib/dpkg/info/<packagename>.postinst并运行dpkg --configure --pending通常会有所帮助。

但通常大胆警告适用:不要盲目遵循这样的建议:包配置脚本不只是会出错并让用户不满意——它们通常执行某些配置或清理等,因此描述的措施应该被视为最后的手段。

相关内容