首先让我提一下,我已经看了很多建议的问题,但没有找到相关的答案。这就是我正在做的。
我连接到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.
解决这个问题的方法非常简单!
在我的例子中,我已经将我的数据库(mysqldump)导出到一个转储文件中。
然后我将文件复制到目标服务器。
在这个目标服务器上,我创建了目标数据库
然后运行命令将复制的dumpfile导入目标服务器上的新目标数据库。
= = >错误!在这一点上,我只是得到了错误,你也得到了!
现在,想想看!你使用的用户,他在源数据库上有什么GRANT ?
他对新的目标数据库有什么情报?
我认为,你已经看到了问题和解决方案!
= = >解决方案!
所以我进入我的源数据库并导出我使用的用户的所有授权。
之后,我进入我的目标数据库并导入导出的GRANT。
瞧!在此之后,将目标服务器上的源数据库导入到新的目标数据库中工作,没有任何问题!
文字太多了,抱歉!但也许它会帮助某人解决一个问题:-)