MySQL 用户 debian-sys-maint 的访问被拒绝
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11644300/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
access denied for user debian-sys-maint
提问by Bartosz Kowalczyk
I have had problem with mysql. I tried to execute this:
我在使用 mysql 时遇到了问题。我试图执行这个:
echo "show databases" | mysql -B -N
But I got:
但我得到了:
ERROR 1045 (28000): Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)
But when I exec:
但是当我执行:
/etc/init.d/mysql restart
I got an 'OK'.
我得到了一个“好的”。
I did
我做了
GRANT ALL PRIVILEGES on *.* TO debian-sys-maint@localhost IDENTIFIED BY PASSWORD 'your password' WITH GRANT OPTION; FLUSH PRIVILEGES;
where password is from /etc/mysql/debian.cnf
. But it didn't help. (of course I flushed priv and restarted mysql).
密码来自哪里/etc/mysql/debian.cnf
。但它没有帮助。(当然,我刷新了 priv 并重新启动了 mysql)。
采纳答案by poncha
The problem is, your GRANT
statement uses IDENTIFIED BY PASSWORD
clause, and in this case mysql expect to get a hashedpassword, not a plaintext one.
问题是,您的GRANT
语句使用IDENTIFIED BY PASSWORD
子句,在这种情况下,mysql 期望获得散列密码,而不是明文密码。
Use IDENTIFIED BY 'your password'
instead, if you wish to supply a plaintext password.
IDENTIFIED BY 'your password'
如果您希望提供纯文本密码,请改用。
回答by Omesh
That's because Debian has a MySQL account debian-sys-maint
used for switching on/off and checking status. The password for that user should be the same as stored in /etc/mysql/debian.cnf
. The file looks like this:
那是因为 Debian 有一个 MySQL 帐户debian-sys-maint
用于打开/关闭和检查状态。该用户的密码应与存储在/etc/mysql/debian.cnf
. 该文件如下所示:
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = debian-sys-maint
password = <password>
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = <password>
socket = /var/run/mysqld/mysqld.sock
basedir = /usr
If the password doesn't match (for example because you changed it manually) the init script won't work anymore. You should set the password according to the file. So
如果密码不匹配(例如因为您手动更改了密码),init 脚本将不再起作用。您应该根据文件设置密码。所以
mysql -u root -p
# Then type MySQL root password
GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '<password>';
回答by shgnInc
Most easy way to restoring the debian-sys-maint user, is to reconfigure package mysql-server-5.5. That if you know the password for the root user of MySQL, you can try to restore the user and its password in /etc/mysql/debian.cnf.
恢复 debian-sys-maint 用户的最简单方法是重新配置软件包 mysql-server-5.5。那如果你知道 MySQL 的 root 用户的密码,你可以尝试在 /etc/mysql/debian.cnf 中恢复用户和它的密码。
sudo dpkg-reconfigure mysql-server-5.5
NOTE: if you cannot stop mysql pid, just run sudo killall mysqld
. This is needed for reconfiguring the mysql-server-5.5.
注意:如果您无法停止 mysql pid,只需运行sudo killall mysqld
. 这是重新配置 mysql-server-5.5 所必需的。