这种情况已经持续了几个星期。除了这个之外,其他所有软件包升级都没有问题,但我不确定是什么原因导致的,也不知道该如何调试。
sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be upgraded:
percona-server-server-5.5
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/22.1 MB of archives.
After this operation, 845 kB disk space will be freed.
Do you want to continue [Y/n]?
Preconfiguring packages ...
(Reading database ... 684209 files and directories currently installed.)
Preparing to replace percona-server-server-5.5 5.5.30-rel30.1-465.precise (using .../percona-server-server-5.5_1%3a5.5.30-rel30.2-503.precise_amd64.deb) ...
* Stopping MySQL (Percona Server) mysqld [fail]
invoke-rc.d: initscript mysql, action "stop" failed.
dpkg: warning: subprocess old pre-removal script returned error exit status 1
dpkg - trying script from the new package instead ...
* Stopping MySQL (Percona Server) mysqld [fail]
invoke-rc.d: initscript mysql, action "stop" failed.
dpkg: error processing /var/cache/apt/archives/percona-server-server-5.5_1%3a5.5.30-rel30.2-503.precise_amd64.deb (--unpack):
subprocess new pre-removal script returned error exit status 1
* Stopping MySQL (Percona Server) mysqld [fail]
invoke-rc.d: initscript mysql, action "stop" failed.
* Starting MySQL (Percona Server) database server mysqld [ OK ]
Errors were encountered while processing:
/var/cache/apt/archives/percona-server-server-5.5_1%3a5.5.30-rel30.2-503.precise_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
答案1
首先停止 mysql。然后运行更新。然后它应该可以工作。
编辑。在运行更新之前,请尝试
sudo service mysql stop
然后
sudo apt-get upgrade
然后你可以做
service mysql start
如果仍然有问题,那么您可能需要检查“sudo service mysql stop”命令是否没有留下任何 MySQL 进程。您可以使用以下命令检查进程。解释 ps 的输出超出了本答案的范围 ps -ef |grep mysql
但为了完整性,以下是我在 MySQL 运行时得到的结果
root@control:~# ps -ef |grep mysql
root 1304 1 0 Oct24 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe
mysql 2568 1304 6 Oct24 ? 10:55:04 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql/ --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/lib/mysql/mysql-error.log --open-files-limit=65535 --pid-file=/var/lib/mysql/mysql.pid --socket=/var/run/mysqld/mysqld.sock
root 4492 23102 0 11:32 pts/3 00:00:00 grep --color=auto mysql
... 当 MySQL 停止时...
root@control:~# ps -ef |grep mysql
root 4492 23102 0 11:32 pts/3 00:00:00 grep --color=auto mysql
答案2
我遇到了完全相同的问题,唯一能解决它的方法就是杀死 mysql:
ps aux | grep mysql
mysql 1325 10.3 3.3 2216444 309324 ? Sl Sep24 22:38 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/
lib/mysql/ecom-mysql.err --pid-file=/var/lib/mysql/ecom-mysql.pid --socket=/var/run/mysqld/mysqld.sock --port=3306
sudo kill -9 1325
sudo apt-get update && sudo apt-get dist-upgrade
答案3
我在 Debian Wheezy 上也遇到了这个问题。我所能做的就是手动终止 mysql 进程,运行我的 apt-get update,这样就没问题了。