MySQL 5.7 升级无法完成

MySQL 5.7 升级无法完成

APT 无法为我升级 mySQL。我认为 1045 错误是由于登录详细信息造成的。我可以运行 mysql_upgrade -uroot -p 并手动完成它,但我该如何告诉 apt 它已完成,请停止尝试?

Setting up mysql-server-5.7 (5.7.24-0ubuntu0.16.04.1) ...
update-alternatives: warning: forcing reinstallation of alternative /etc/mysql/mysql.cnf because link group my.cnf is broken
update-alternatives: warning: not replacing /etc/mysql/my.cnf with a link
mysql_upgrade: Got error: 1045: Unknown error 1045 while connecting to the MySQL server
Upgrade process encountered error and will not continue.
mysql_upgrade failed with exit status 11
dpkg: error processing package mysql-server-5.7 (--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.7; however:
  Package mysql-server-5.7 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 mysql-server-5.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

我必须使用 /etc/mysql/debian.cnf 中的密码重新创建 debian-sys-maint 用户

GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY 'PASSWORD';

答案2

如果您在启动时禁用了 mysql 服务,升级脚本将无法完成更新过程。因此,您可以像下面这样在启动时启用 mysql 服务并进行升级,

sudo systemctl enable mysql.service

sudo apt update

sudo apt upgrade -y

如果要在启动时禁用 mysql 服务,可以按如下方式禁用它,

sudo systemctl disable mysql.service

相关内容