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

我连接到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)的访问被拒绝


当前回答

操作系统:windows

我的错误信息是:

MySQL ERROR 1045(28000):用户'root'@'localhost'(使用密码:YES)被拒绝访问

我的原因是,我没有打开cmd与管理员权限。

所以我的解决方案是作为管理员打开cmd,然后它就工作了。

其他回答

Try:

~$ mysql -u root -p
Enter Password:

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

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。

瞧!在此之后,将目标服务器上的源数据库导入到新的目标数据库中工作,没有任何问题!

文字太多了,抱歉!但也许它会帮助某人解决一个问题:-)

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

在Windows上,解决方法如下:

错误1045(28000):拒绝访问用户'root'@'localhost'(使用密码:NO)

从控制面板卸载mysql 删除C:\Program Files,C:\Program Files (x86)和C:\ProgramData目录下的MySql文件夹 安装mysql