- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
首先让我提一下,我已经浏览了许多建议的问题,但没有找到相关的答案。这就是我正在做的事情。
我已连接到我的 Amazon EC2 实例。我可以使用以下命令使用 MySQL root 登录:
mysql -u root -p
然后我使用主机 % 创建了一个新的用户账单
CREATE USER 'bill'@'%' IDENTIFIED BY 'passpass';
授予用户 bill 所有权限:
grant all privileges on *.* to 'bill'@'%' with grant option;
然后我退出 root 用户并尝试使用 bill 登录:
mysql -u bill -p
输入了正确的密码并收到此错误:
ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)
最佳答案
您可能有一个匿名用户''@'localhost'
或''@'127.0.0.1'
。
根据the manual :
When multiple matches are possible, the server must determine which ofthem to use. It resolves this issue as follows: (...)
- When a client attempts to connect, the server looks through the rows [of table mysql.user] in sorted order.
- The server uses the first row that matches the client host name and user name.
(...)The server uses sorting rules that order rows with the most-specific Host values first.Literal host names [such as 'localhost'] and IP addresses are the most specific.
因此,当从 localhost
连接时,这样的匿名用户会“屏蔽”任何其他用户,例如 '[any_username]'@'%'
。
'bill'@'localhost'
确实匹配 'bill'@'%'
,但会匹配(例如)''@'localhost'
事先。
推荐的解决方案是删除该匿名用户(无论如何,这通常是一件好事)。
<小时/>以下编辑大多与主要问题无关。这些只是为了回答本主题中其他评论中提出的一些问题。
编辑 1
通过套接字验证为 'bill'@'%'
。
root@myhost:/home/mysql-5.5.16-linux2.6-x86_64# ./mysql -ubill -ppass --socket=/tmp/mysql-5.5.sock Welcome to the MySQL monitor (...) mysql> SELECT user, host FROM mysql.user; +------+-----------+ | user | host | +------+-----------+ | bill | % | | root | 127.0.0.1 | | root | ::1 | | root | localhost | +------+-----------+ 4 rows in set (0.00 sec) mysql> SELECT USER(), CURRENT_USER(); +----------------+----------------+ | USER() | CURRENT_USER() | +----------------+----------------+ | bill@localhost | bill@% | +----------------+----------------+ 1 row in set (0.02 sec) mysql> SHOW VARIABLES LIKE 'skip_networking'; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | skip_networking | ON | +-----------------+-------+ 1 row in set (0.00 sec)
编辑2
完全相同的设置,只是我重新激活了网络,并且现在创建了一个匿名用户''@'localhost'
。
root@myhost:/home/mysql-5.5.16-linux2.6-x86_64# ./mysql Welcome to the MySQL monitor (...) mysql> CREATE USER ''@'localhost' IDENTIFIED BY 'anotherpass'; Query OK, 0 rows affected (0.00 sec) mysql> Bye root@myhost:/home/mysql-5.5.16-linux2.6-x86_64# ./mysql -ubill -ppass \ --socket=/tmp/mysql-5.5.sock ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES) root@myhost:/home/mysql-5.5.16-linux2.6-x86_64# ./mysql -ubill -ppass \ -h127.0.0.1 --protocol=TCP ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES) root@myhost:/home/mysql-5.5.16-linux2.6-x86_64# ./mysql -ubill -ppass \ -hlocalhost --protocol=TCP ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)
编辑3
与编辑 2 中的情况相同,现在提供匿名用户的密码。
root@myhost:/home/mysql-5.5.16-linux2.6-x86_64# ./mysql -ubill -panotherpass -hlocalhost Welcome to the MySQL monitor (...) mysql> SELECT USER(), CURRENT_USER(); +----------------+----------------+ | USER() | CURRENT_USER() | +----------------+----------------+ | bill@localhost | @localhost | +----------------+----------------+ 1 row in set (0.01 sec)
结论 1,来自编辑 1:可以通过套接字以 'bill'@'%'
身份进行身份验证。
编辑 2 中的结论 2:无论是通过 TCP 还是通过套接字连接,对身份验证过程都没有影响(除非一个人无法像其他人一样通过 'something'@'localhost'
进行连接)显然是一个套接字)。
结论 3,来自编辑 3:虽然我指定了 -ubil
,但我已被授予匿名用户访问权限。这是因为上面建议的“排序规则”。请注意,在大多数默认安装中,a no-password, anonymous user exists (并且应该固定/删除)。
关于MySQL 错误 1045 (28000) : Access denied for user 'bill' @'localhost' (using password: YES),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56352934/
谁能解释一下 localhost:5000 之间的区别和其他本地主机。 谢谢你。 最佳答案 localhost:5000 正在访问端口 5000 上的 localhost。 例如,如果您从浏览器访问它
假设本地 Python 脚本正在运行网络服务器。 有没有办法设置别名,以便http://localwebapp/等于 http://localhost:1234/ ? 编辑:或至少 http://lo
我对网络开发完全陌生。所以我总是看到“localhost”之类的东西并问自己:那是什么? 我感觉知道什么是“主持人”了。执行某事的东西。所以我的 Mac 是其上运行的所有内容的主机。那么“localh
我正在学习 xmpp 编程,我使用 sudo apt-get install ejabberd 在我的 ubuntu 15.10 上安装了 ejabberd,然后我通过添加管理员用户 ejabberd
是否总是可以 ping localhost 并解析为 127.0.0.1? 我知道 Windows Vista、XP、Ubuntu 和 Debian 都这样做,但每个人都这样做吗? 最佳答案 任何正确
我们在同一台计算机上使用客户端/服务器 RMI 通信(因此所有 ip 都应该是本地主机)。 我们启动注册表(使用默认端口1099) registry = LocateRegistry.createRe
我已经在 windows/system32/drivers/etc/ 中验证了我的主机文件其中有一个 localhost 的条目,但它不会去任何地方。我必须在 URL 中有一个端口号:http://1
我的主机上有一个守护程序在某个端口(即 8008)上运行,我的代码通常通过联系 localhost:8008 与守护程序交互。 我现在已经将我的代码容器化了,但还没有将守护进程容器化。如何将容器上的
在 SMTP 中,HELO 命令之后应该是什么,它有什么作用? 我在我的应用程序中发送电子邮件,我想知道我是否应该使用 localhost、发件人地址的域名 (me@example.com)、应用程序
我遇到无法打开本地主机Web应用程序的问题,因为Microsoft Edge会将URL http://localhost:3000重定向到https://localhost:3000。因此,我得到了错
一直在尝试设置我想用于登录的 Facebook 应用程序,以允许我在 Mac 的本地主机上测试它。 Facebook 抛出错误“应用程序域:http://localhost 不是有效域。”当我尝试将站
我在 MacOS 10.15 上使用 minikube 1.4.0 版和 Kubernetes 1.16.0 版。 我正在开发一些依赖于外部服务的授权/认证代码。在对服务的 API 调用中,我需要提供
当我用谷歌搜索这个问题时,我注意到这是 nginx 的一个常见问题。但是我从来没有在我的机器上使用过 nginx。我使用 MAMP,偶尔使用 Python Bottle。 现在,无论我的 MAMP/P
我在本地运行 Squid,我想通过在 localhost:3000 上运行的 Ruby 服务器通过 Squid 进行访问。 如果我尝试访问 localhost:3000,我会收到以下消息: The f
我使用 VS 2012 默认模板创建了 MVC4 移动应用程序。使用 http://localhost/mvcapplication1/ 在桌面浏览器中运行良好但是当我尝试在 WP8 Emulator
如何将默认的 xampp localhost c:xampp/htdoc 更改为另一个文件夹,即 c:/alan?当我使用 IP 地址时,我应该能够在 C:/alan 中查看我的网站文件。 感谢您帮助
我正在使用带有centos版本6(Fedora)的Vmware。我正在使用hadoop 1.0.4版本。我的 http://localhost:50070 地址显示为“无法连接”,但是 http://
我正在运行带有 apache 2.4.38 和 Maria DB 10.1.38 + PHP 7.3.3 的 Windows Server 2016 有时,我可以看到(使用 netstat)从 127
尝试通过 SSH 连接到本地主机时的调试信息 ssh root@localhost -vvv 输出 OpenSSH_6.6.1、OpenSSL 1.0.1f 2014 年 1 月 6 日debug1:
我正在使用 Node 和 Laravel 编写一个应用程序。我正在运行小型 laravel 本地服务器,该服务器解析为 http://localhost:8000 。我还在 localhost:300
我是一名优秀的程序员,十分优秀!