错误1045(28000):用户'username'@'%'的访问被拒绝(使用密码:是) [英] ERROR 1045 (28000): Access denied for user 'username'@'%' (using password: YES)

查看:339
本文介绍了错误1045(28000):用户'username'@'%'的访问被拒绝(使用密码:是)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在CentOS 6.4服务器上安装了MySQL.我登录了root并更改了密码.

I Installed MySQL on my CentOS 6.4 server. I logged into my root and changed its password.

后来我认为我应该创建一个新用户并将该用户用作我的默认用户,所以我使用以下命令创建了一个新用户名golden:

Later I thought that I should make a new user and use that user as my default user, So I created a new user name golden using the following command:

CREATE USER 'golden'@'%' IDENTIFIED BY 'password';

然后我向用户golden申请了权限:

Then I applied permission to the user golden:

GRANT ALL PRIVILEGES ON * . * TO 'golden'@'%';

FLUSH PRIVILEGES;

现在,此用户:golden能够执行所有操作.所以我终于Deleted the root user.现在,我一直在向其他新用户授予特权.

Now this user: golden was able to do everything. So I finally Deleted the root user. Now I am stuck up on granting privilege to my one another new user.

我通过golden登录时创建了另一个用户(这时我已经删除了root用户并成功创建了命令,并且新用户也可以在列表中看到它)

I created another user, when I was logged in through golden (At this time I had already deleted the root user and command successfully created and the new user I am able to see it in list also)

CREATE USER 'fashion'@'%' IDENTIFIED BY 'password';

然后下面的以下命令给我错误:

Then the following commands below gives me error:

GRANT ALL PRIVILEGES ON *.* TO 'fashion'@'%';

错误::错误1045(28000):用户'golden'@'%'的访问被拒绝(使用密码:是)

ERROR: ERROR 1045 (28000): Access denied for user 'golden'@'%' (using password: YES)

我还尝试了以下命令,结果如下:

I also tried the following command the result is below:


mysql> SELECT USER(),CURRENT_USER();
+------------------+----------------+
| USER()           | CURRENT_USER() |
+------------------+----------------+
| golden@localhost | golden@%       |
+------------------+----------------+

如果我将无法授予该用户访问权限,那么我如何登录和使用数据库?请帮助.

If I wont be able to give access to this user then how can I login and use the database? Kindly help.

以下命令为我提供了以下结果


mysql> select user, host FROM mysql.user;
+------------+-------+
| user       | host  |
+------------+-------+
| golden     | %     |
| fashion    | %     |
+------------+-------+

推荐答案

首先,我无法想象您删除root用户的原因.但是回到问题-您应该指定WITH GRANT OPTION,如下所示:

First of, I can't imagine the reason why you've deleted root user. But back to the question - you should specify WITH GRANT OPTION, like this:

(但是,在重新安装mysql之后,应该选择此选项,就像您没有root访问权限并且用户也没有足够的特权一样,那么最好的方法是重新启动安装过程,并按照以下定义的方式授予用户并授予他们特权)

(However this should be opted after you get the mysql re-installed as if you don't have the root access and the user is not having the sufficient privileges also, then the best is to restart the install process and make the user and grant them privileges the way defined below)


mysql> create user 'golden'@'localhost' identified by 'password';
Query OK, 0 rows affected (0.00 sec)

mysql> grant all privileges on *.* to golden@localhost with grant option;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

然后


mysql> select current_user();
+------------------+
| current_user()   |
+------------------+
| golden@localhost |
+------------------+
1 row in set (0.00 sec)

mysql> create database testing;
Query OK, 1 row affected (0.03 sec)

mysql> grant all privileges on testing.* to test;
Query OK, 0 rows affected (0.02 sec)

mysql> drop database testing;
Query OK, 0 rows affected (0.12 sec)

-但是,请再次三思,然后删除root用户.

-but yet again, think twice before deleting root user.

这篇关于错误1045(28000):用户'username'@'%'的访问被拒绝(使用密码:是)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆