我正在使用 Google Cloud,并且我有一个运行良好的虚拟机(Ubuntu 18.04)。apt-get 命令运行完全正常,mysql 服务运行良好。我们将其称为 vm-1
我需要创建另一个重复的虚拟机,因此我首先创建了虚拟机 1 的快照,然后使用该快照创建了一个名为虚拟机 2 的新虚拟机。
当我在 vm-2 上工作时,我发现简单的命令sudo apt-get install ***
会失败并卡在与 mysql-server 相关的步骤上。以下是一个例子:
John@vm-2:~$ sudo apt-get install tree
Reading package lists... Done
Building dependency tree
Reading state information... Done
tree is already the newest version (1.7.0-5).
The following packages were automatically installed and are no longer required:
libnvidia-common-390 linux-gcp-headers-5.0.0-1033
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 170 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up mysql-server-5.7 (5.7.30-0ubuntu0.18.04.1) ...
/var/lib/mysql/ibdata1: 14143
ERROR: Database files are locked. Daemon already running?
Warning: Unable to start the server. Please restart MySQL and run mysql_upgrade to ensure the database is ready for use.
/var/lib/mysql/ibdata1: 14143
ERROR: Database files are locked. Daemon already running?
Warning: Unable to start the server.
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
invoke-rc.d: initscript mysql, action "start" failed.
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Wed 2020-08-12 18:11:39 JST; 7ms ago
Process: 24068 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid (code=exited, status=1/FAILURE)
Process: 24046 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 1711 (code=exited, status=0/SUCCESS)
dpkg: error processing package mysql-server-5.7 (--configure):
installed mysql-server-5.7 package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-5.7; however:
Package mysql-server-5.7 is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
mysql-server-5.7
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
John@vm-2:~$
它一直这么说
ERROR: Database files are locked. Daemon already running?
Warning: Unable to start the server. Please restart MySQL and run mysql_upgrade to ensure the database is ready for use.
/var/lib/mysql/ibdata1: 14143
ERROR: Database files are locked. Daemon already running?
Warning: Unable to start the server.
apt-get 和 mysql-server 有什么关系?我一直以为它们是两个独立的软件。
我该如何解决这个问题?我什么都没做,只是恢复了原始虚拟机中完全正常运行的快照。一切都一样,怎么会apt-get
失败呢?
答案1
以下日志行:
2 not fully installed or removed.
表明 apt-get 正在尝试在继续新的安装请求(树)之前完成早期失败的软件包安装(mysql-server-5.7),这就是您在该输出中看到提到的 mysql-server 的原因。
我建议确定 mysql 服务器是否已通过ps -ef | grep -i mysql
或运行,netstat -lntp | grep 3306
并解决导致的问题ERROR: Database files are locked. Daemon already running?
一旦解决了这个问题,之前的软件包安装就会成功完成
如果您手动启动了 mysql,那么我建议停止该过程,然后再次运行原始命令。
如果你之前曾以 身份启动过 mysql
root
,那么你可能需要检查/var/lib/mysql/ibdata1
文件夹中文件的权限