首先让我提一下,我已经看了很多建议的问题,但没有找到相关的答案。这就是我正在做的。
我连接到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)的访问被拒绝
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.
只是想让你知道一个不寻常的情况下,我收到了同样的错误。也许这在将来会对某些人有所帮助。
我开发了一些基本视图,在开发站点创建,并将它们转移到生产站点。那周晚些时候,我修改了一个PHP脚本,突然出现了一个错误,用户“local-web-user”@“localhost”的访问被拒绝。数据源对象没有改变,所以我把注意力集中在MySQL中的数据库用户上,同时担心有人入侵我的网站。幸运的是,遗址的其他部分似乎没有受到损害。
后来证明,这些观点才是罪魁祸首。我们的对象传输是使用本地网站用户以外的另一个用户(并且是远程:admin@ip-address)完成的。因此,视图是用'admin'@'ip-address'作为定义符创建的。视图创建SECURITY default为
SQL SECURITY DEFINER
当local-web-user试图使用视图时,它会偶然发现定义者缺乏使用表的特权。一旦安全性更改为:
SQL SECURITY INVOKER
问题解决了。实际问题与基于错误消息的预期完全不同。