![如何解决 mysql 上的无人值守升级?](https://linux22.com/image/1021661/%E5%A6%82%E4%BD%95%E8%A7%A3%E5%86%B3%20mysql%20%E4%B8%8A%E7%9A%84%E6%97%A0%E4%BA%BA%E5%80%BC%E5%AE%88%E5%8D%87%E7%BA%A7%EF%BC%9F.png)
我有 2 个mysql
更新无法安装在 20.04 上:
2 updates could not be installed automatically. For more details,
see /var/log/unattended-upgrades/unattended-upgrades.log
我尝试了以下操作:
$ sudo apt install mysql-server-8.0 mysql-client-8.0
The following packages have unmet dependencies:
mysql-client-8.0 : Depends: mysql-common (>= 5.5)
mysql-server-8.0 : PreDepends: mysql-common (>= 5.5)
Depends: mysql-common (>= 5.8+1.0.4~)
$ sudo apt-get --with-new-pkgs upgrade
The following packages have been kept back:
mysql-client mysql-server
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
$ sudo apt list mysql* --installed
mysql-apt-config/now 0.8.16-1 all [installed,local]
mysql-client/now 8.0.22-1ubuntu18.04 amd64 [installed,upgradable to: 8.0.23-0ubuntu0.20.04.1]
mysql-common/now 8.0.22-1ubuntu18.04 amd64 [installed,local]
mysql-community-client-core/now 8.0.22-1ubuntu18.04 amd64 [installed,local]
mysql-community-client-plugins/now 8.0.22-1ubuntu18.04 amd64 [installed,local]
mysql-community-client/now 8.0.22-1ubuntu18.04 amd64 [installed,local]
mysql-community-server-core/now 8.0.22-1ubuntu18.04 amd64 [installed,local]
mysql-community-server/now 8.0.22-1ubuntu18.04 amd64 [installed,local]
mysql-server/now 8.0.22-1ubuntu18.04 amd64 [installed,upgradable to: 8.0.23-0ubuntu0.20.04.1]
我该如何解决这些问题?
答案1
您的计算机上似乎同时安装了 MySQL Server 和 MySQL Community Server,这可能会导致大量冲突。MySQL Server 是 Canonical 为 Ubuntu 推出的版本,而 MySQL Community Server 是由 Oracle 以自己的发布节奏推出的。您需要选择其中一个,并且希望被删除的那个不会破坏剩下的那个。
最合理的方法可能是删除 MySQL 服务器和 MySQL 社区服务器,然后重新安装要使用的那个。在此过程中,您现有的数据库文件和配置不应丢失,但请准备好备份以防万一。
事情要做的顺序如下:
确保 MySQL 没有运行:
$ sudo service mysql status
如果你看到类似这样的内容:
● mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2021-02-02 06:40:54 JST; 6 days ago Main PID: 112265 (mysqld) Status: "Server is operational" Tasks: 157 (limit: 9204) Memory: 758.9M CGroup: /system.slice/mysql.service └─112265 /usr/sbin/mysqld 2月 02 06:40:53 Carbon systemd[1]: Starting MySQL Community Server... 2月 02 06:40:54 Carbon systemd[1]: Started MySQL Community Server.
然后您需要像这样停止服务器:$ sudo service mysql stop
sudo apt list mysql* - -installed
删除列出的您已在问题中提供的MySQL 包:$ sudo apt purge mysql-server mysql-client \ mysql-common mysql-server-core-* mysql-client-core-* \ mysql-community-server mysql-community-server-core-* \ mysql-community-client mysql-community-client-*
您将获得一个很长的要删除的软件包列表。仔细阅读所有内容,确保不会出现可能破坏系统上运行的其他重要软件包的意外情况。如果一切正常,请继续删除。
干净的
apt
:$ sudo apt autoremove $ sudo apt autoclean
重新安装您想要的 MySQL 版本(例如,Canonical 提供的版本):
$ sudo apt install mysql-server
运行安全安装程序并设置一个好的
root
密码:$ sudo mysql_secure_installation
完成后,连接到 MySQL,记住在 8.0 及以上版本中,您需要
sudo
以如下方式连接root
:$ sudo mysql
如果到目前为止一切顺利,请检查您的数据库是否仍然存在,如果您还没有管理员帐户,
SHOW DATABASES
请考虑创建一个管理员帐户来访问 MySQL 。sudo
(可选步骤)确认已安装的 MySQL 包:
$ sudo apt list mysql* --installed Listing... Done mysql-client-8.0/focal-security,now 8.0.23-0ubuntu0.20.04.1 amd64 [installed,automatic] mysql-client-core-8.0/focal-security,now 8.0.23-0ubuntu0.20.04.1 amd64 [installed,automatic] mysql-client/focal-security,focal-security,now 8.0.23-0ubuntu0.20.04.1 all [installed] mysql-common/focal,focal,now 5.8+1.0.5ubuntu2 all [installed,automatic] mysql-server-8.0/focal-security,now 8.0.23-0ubuntu0.20.04.1 amd64 [installed,automatic] mysql-server-core-8.0/focal-security,now 8.0.23-0ubuntu0.20.04.1 amd64 [installed,automatic] mysql-server/focal-security,focal-security,now 8.0.23-0ubuntu0.20.04.1 all [installed]
希望这能帮助你再次跑步