我正在尝试安装 mysql 但出现错误:
mysql_upgrade: Got error: 1045: Access denied for user 'debian-sys-maint'@'localhost' (using password: YES) while connecting to the MySQL server
经过一番搜索,我发现这也许可以访问 debian-sys-maint,所以我这样做了:
sudo cat /etc/mysql/debian.cnf
然后在mysql中设置debian密码:
mysql -u root -p <password>
GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY 'password-here';
然后我重新启动:
sudo /etc/init.d/mysql restart
并尝试再次配置:
sudo dpkg --configure -a
我犯了同样的错误。
答案1
虽然有点晚了,但还是要说:首先,我在
Distributor ID: Ubuntu
Description: Ubuntu 16.10
Release: 16.10
Codename: yakkety
我不得不“取消选中”一些软件存储库。这可以在选项卡Software & Updates
上的 GUI上轻松完成Other Software
。我取消选中了:
- 不稳定的存储库
- xenial 存储库
- “升级到 yakkety 时禁用”存储库
我唯一检查过的存储库是:
然后,我通过以下方式解决了这个问题:
sudo su
root@1w3j: mysql -u root -p
Enter password:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '<your password>';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
如果出现错误(1819),请在 mysql 终端上输入此内容
mysql> uninstall plugin validate_password;
然后重启mysql:systemctl restart mysql
最后
apt install -f
修复损坏的依赖关系
如果错误仍然存在,请再次进入 mysql 终端,登录:输入:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '<your password>'
apt -f install
最后一次。
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
libmecab2
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up mysql-server-5.7 (5.7.17-0ubuntu0.16.10.1) ...
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
Checking system database.
mysql.columns_priv OK
mysql.db OK
mysql.engine_cost OK
mysql.event OK
mysql.func OK
mysql.general_log OK
mysql.gtid_executed OK
mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
mysql.ndb_binlog_index OK
mysql.plugin OK
mysql.proc OK
mysql.procs_priv OK
mysql.proxies_priv OK
mysql.server_cost OK
mysql.servers OK
mysql.slave_master_info OK
mysql.slave_relay_log_info OK
mysql.slave_worker_info OK
mysql.slow_log OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
The sys schema is already up to date (version 1.5.1).
Checking databases.
(your databases will be shown here...)
Upgrade process completed successfully.
Checking if update is needed.
Setting up mysql-server (5.7.17-0ubuntu0.16.10.1) ...
其他解决方法是:apt -u dist-upgrade
答案2
这是在多次尝试回答这个问题之后得出的结论
检查 MYSQL 安装中的用户
mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
+-----------+-------------------------------------------+-----------------------+-----------+
| User | authentication_string | plugin | Host |
+-----------+-------------------------------------------+-----------------------+-----------+
| root | *4C856331B587C990CC0D06E7EC93CB2D7A2CAD5F | mysql_native_password | localhost |
| mysql | invalid | mysql_native_password | localhost |
| wordpress | *2D2CF7300069DAB3433A5A0F49B92407769EBC56 | mysql_native_password | localhost |
+-----------+-------------------------------------------+-----------------------+-----------+
创建 Debian-sys-maint用户
mysql> CREATE USER 'debian-sys-maint'@'localhost' IDENTIFIED BY 'password';
使用 debian.cnf 文件中的相同密码
user@system:~$ sudo cat /etc/mysql/debian.cnf
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = debian-sys-maint
password = **n4aSHUP04s1J32X5**
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
user = debian-sys-maint
password = **n4aSHUP04s1J32X5**
socket = /var/run/mysqld/mysqld.sock
basedir = /usr
mysql> CREATE USER 'debian-sys-maint'@'localhost' IDENTIFIED BY 'n4aSHUP04s1J32X5';
授予 Debian-sys-maint 用户访问权限
mysql> GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
mysql> EXIT