首先让我提一下,我已经看了很多建议的问题,但没有找到相关的答案。这就是我正在做的。

我连接到Amazon EC2实例。我可以用这个命令登录MySQL根目录:

mysql -u root -p

然后我用host %创建了一个新的用户帐单

CREATE USER 'bill'@'%' IDENTIFIED BY 'passpass';

授予用户bill的所有权限:

grant all privileges on *.* to 'bill'@'%' with grant option;

然后我退出root用户,尝试用bill登录:

mysql -u bill -p

输入正确的密码并得到以下错误:

错误1045(28000):用户“账单”@“localhost”(使用密码:YES)的访问被拒绝


当前回答

如果您使用旧版本的MySQL UI(如SQLYoug),生成的密码带有错误的散列,也会出现这个问题。

用SQL脚本创建用户可以解决这个问题。

其他回答

我通过删除旧的错误用户“账单”条目来解决这个问题(这是重要的部分:都来自mysql。用户和mysql.db),然后创建和前面一样的用户:

FLUSH PRIVILEGES;
CREATE USER bill@localhost IDENTIFIED BY 'passpass';
grant all privileges on *.* to bill@localhost with grant option;
FLUSH PRIVILEGES;

工作完毕,用户正在连接。现在我将删除一些特权从它:)

I discovered yet another case that appears on the surface to be an edge case; I can export to the file system, via SELECT INTO .. OUTFILE as root, but not as regular user. While this may be a matter of permissions, I've looked at that, and see nothing especially obvious. All I can say is that executing the query as a regular user who has all permissions on the data base in question returns the access denied error that led me to this topic. When I found the transcript of a successful use of SELECT INTO … OUTFILE in an old project, I noticed that I was logged in as root. Sure enough, when I logged in as root, the query ran as expected.

我有类似的问题,因为我的密码包含“;”字符破坏我的密码时,我第一次创建它。如果对你有帮助,请谨慎使用。

如果MySQL运行在不区分大小写的操作系统(如Windows)上,也可能发生这种情况。

例:我发现尝试使用这些凭据连接到数据库失败:

mysql>授予数据库ev105的select权限。*到'specialuser',标识为's3curepa5wrd';

$ mysql -specialuser' -p's3curepa5wrd' -h10.61.130.89 databaseV105

错误1045(28000):拒绝访问用户'specialuser'@'10.0.1.113'(使用密码:YES)

但是,这成功了:

Mysql >授予select权限*到'specialuser',标识为's3curepa5wrd';

mysql ' - h10300,300,400 database105 -p

输入密码:

省得你自己头疼……您的问题可能是口令周围没有引号。至少我的案子绕了我三个小时。

[client]
user = myusername
password = "mypassword"   # <----------------------- VERY IMPORTANT (quotes)
host = localhost

http://dev.mysql.com/doc/refman/5.7/en/option-files.html

搜索“这是一个典型的用户选项文件:”,看看他们在那里陈述的例子。祝你好运,我希望能为别人节省一些时间。