MYSQL 权限:拒绝用户“debian-sys-maint”@“localhost”的访问

MYSQL 权限:拒绝用户“debian-sys-maint”@“localhost”的访问

在 Debian 上安装 mysql 服务器时出现问题。(这不是我的服务器,所以我不知道是什么原因造成的...)

安装添加数据库的新应用程序失败并出现错误:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

我可以用该用户登录,我已经刷新了权限...

然后我可以回答这个问题: https://stackoverflow.com/questions/1709078/how-can-i-restore-the-mysql-root-users-full-privileges

但是当我尝试停止 mysql 时,它失败了

error: 'Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)'

答案1

Debian 使用 debian-sys-maint 帐户进行管理(启动/停止等)。凭证存储在/etc/mysql/debian.cnf- 检查是否全部有效。

答案2

恢复用户的方法有很多种debian-sys-maint。最简单的方法是重新配置包mysql-server-5.5。如果您知道 MySQL 用户的密码root,您可以尝试在 中恢复用户及其密码/etc/mysql/debian.cnf

sudo dpkg-reconfigure mysql-server-5.5

要恢复 MySQL 的root密码(或任何 MySQL 用户的密码),您可以使用该debian-sys-maint帐户。您需要运行mysql以获取该帐户的密码debian-sys-maint

sudo mysql --defaults-file=/etc/mysql/debian.cnf
mysql> UPDATE mysql.user SET Password=PASSWORD('secret') WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> QUIT;

所以,绝不删除用户debian-sys-maint,因为它在 Debian 中用于管理 MySQL(关闭它、滚动日志、升级软件包、检查rootMySQL 中用户的存在、设置新root用户密码等)。

相关内容