首先,让我提一下,我已经提出了许多建议问题,但没有找到相关的答案。这就是我要做的。
我已连接到我的亚马逊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):拒绝访问用户'bill'@'localhost‘(使用密码: YES)
发布于 2012-10-26 04:17:58
尝试:
~$ mysql -u root -p
Enter Password:
mysql> grant all privileges on *.* to bill@localhost identified by 'pass' with grant option;
发布于 2012-06-27 01:40:32
当你跑步的时候
mysql -u bill -p
并得到了这个错误
ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)
mysqld希望您以bill@localhost
身份连接
尝试创建bill@localhost
CREATE USER bill@localhost IDENTIFIED BY 'passpass';
grant all privileges on *.* to bill@localhost with grant option;
如果要远程连接,则必须使用TCP/ IP指定DNS名称、公用IP或127.0.0.1:
mysql -u bill -p -hmydb@mydomain.com
mysql -u bill -p -h10.1.2.30
mysql -u bill -p -h127.0.0.1 --protocol=TCP
登录后,请运行以下命令
SELECT USER(),CURRENT_USER();
USER()报告您尝试在MySQL中进行身份验证的方式
CURRENT_USER()将从mysql.user表中报告如何允许您在MySQL中进行身份验证
这将使您更好地了解允许您登录mysql的方式和原因。为什么了解这个视图很重要?它与用户身份验证排序协议有关。
下面是一个示例:我将在我的桌面MySQL上创建一个匿名用户
mysql> select user,host from mysql.user;
+---------+-----------+
| user | host |
+---------+-----------+
| lwdba | % |
| mywife | % |
| lwdba | 127.0.0.1 |
| root | 127.0.0.1 |
| lwdba | localhost |
| root | localhost |
| vanilla | localhost |
+---------+-----------+
7 rows in set (0.00 sec)
mysql> grant all on *.* to x@'%';
Query OK, 0 rows affected (0.02 sec)
mysql> select user,host from mysql.user;
+---------+-----------+
| user | host |
+---------+-----------+
| lwdba | % |
| mywife | % |
| x | % |
| lwdba | 127.0.0.1 |
| root | 127.0.0.1 |
| lwdba | localhost |
| root | localhost |
| vanilla | localhost |
+---------+-----------+
8 rows in set (0.00 sec)
mysql> update mysql.user set user='' where user='x';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> select user,host from mysql.user;
+---------+-----------+
| user | host |
+---------+-----------+
| | % |
| lwdba | % |
| mywife | % |
| lwdba | 127.0.0.1 |
| root | 127.0.0.1 |
| lwdba | localhost |
| root | localhost |
| vanilla | localhost |
+---------+-----------+
8 rows in set (0.00 sec)
mysql>
好的,看我以匿名用户的身份登录:
C:\MySQL_5.5.12>mysql -urol -Dtest -h127.0.0.1 --protocol=TCP
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.5.12-log MySQL Community Server (GPL)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select user(),current_user();
+---------------+----------------+
| user() | current_user() |
+---------------+----------------+
| rol@localhost | @% |
+---------------+----------------+
1 row in set (0.00 sec)
mysql>
身份验证顺序非常严格。它从最具体到最少进行检查。。
必要时,不要忘记显式地调用TCP作为mysql客户端的协议。
发布于 2016-10-04 07:46:04
太迟了
我尝试了所有这些其他答案,并运行了许多不同版本的mysql -u root -p
,但从未运行过
mysql -u root -p
只需按[ENTER]
输入密码即可。
一旦我这样做了,它就起作用了。希望这对某些人有帮助。
https://stackoverflow.com/questions/10299148
复制相似问题