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

我连接到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 -u root -p,但从来没有运行过


Mysql -u root -p

然后按[ENTER]输入密码。


一旦我这么做了,就成功了。希望这能帮助到一些人。

其他回答

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.

不确定其他人是否会发现这有帮助,但我遇到了同样的错误,并搜索任何匿名用户…但实际上并没有。问题最终是用户帐户被设置为“要求SSL”-这是我在PHPMyAdmin通过进入用户帐户并单击编辑用户的权限发现的。只要我取消了这个选项,一切都按预期工作!

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

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

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

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

在我的情况下,服务器托管我的代码是发送'@blablabla.amazonaws.com'在用户名的ed时,试图登录MySQL。所以我不得不将%.amazonws.com添加到我的主机的用户配置(dreamhost)中,它通过了

Try:

~$ mysql -u root -p
Enter Password:

mysql> grant all privileges on *.* to bill@localhost identified by 'pass' with grant option;