![MySQL 5.7 升级无法完成](https://linux22.com/image/1010335/MySQL%205.7%20%E5%8D%87%E7%BA%A7%E6%97%A0%E6%B3%95%E5%AE%8C%E6%88%90.png)
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