我正在使用谷歌云,我有一个运行良好的虚拟机(Ubuntu 18.04)。apt-get 命令运行良好,mysql 服务运行良好。我们称它为 vm-1
我需要创建另一个重复的 vm,所以我首先制作了 vm-1 的快照,并使用此快照创建了一个新的 vm,称为 vm-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
会失败?
以下日志行:
2 not fully installed or removed.
表明 apt-get 在继续执行新的安装请求(树)之前尝试完成先前失败的软件包安装(mysql-server-5.7),这就是您在该输出中看到 mysql-server 的原因。我建议确定 mysql 服务器是否已经通过
ps -ef | grep -i mysql
or运行netstat -lntp | grep 3306
并解决导致的问题ERROR: Database files are locked. Daemon already running?
一个这个解决了,它将允许之前的包安装成功完成
如果您自己手动启动 mysql,那么我建议您停止该进程,然后再次运行原始命令。
如果有可能如果您之前在某个时间点启动了 mysql
root
,您可能需要检查文件/var/lib/mysql/ibdata1
夹中文件的权限