使用正确的凭据拒绝访问,这是怎么回事? [英] Access denied with correct credentials, what is going on?

查看:125
本文介绍了使用正确的凭据拒绝访问,这是怎么回事?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为根用户:

GRANT ALL PRIVILEGES ON * . * To 'JKR'@'%' IDENTIFIED BY "";
FLUSH PRIVILEGES;

在PHP中:

$con = new PDO("mysql:host=127.0.0.1;dbname=jkr;charset=utf8", "JKR", "");

错误消息:

Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database 'jkr'' in C:\xampp\www\jkr\core\connect.php:6

由于某些原因仅作为root用户使用...
还有为什么我得到用户'@'localhost'拒绝访问?

Only works as root for some reason ... Also how come I get Access denied for user ''@'localhost'?

推荐答案

您的系统上很可能有一个匿名用户''@@'localhost'

Most likely you have an anonymous user ''@'localhost' on your system. An anonymous user is a user where the name is ignored.

如果您使用 JKR 来自 localhost 它将使您与匿名用户匹配。

If you connect to MySQL with JKR coming from localhost it will match you with the anonymous user.

您可以使用 SELECT用户进行检查,来自mysql.user的主机;

请参见 https://dev.mysql.com/doc/refman/5.7/en/connection-access.html 详细讨论了MySQL匹配的方式用户和请求。

See https://dev.mysql.com/doc/refman/5.7/en/connection-access.html for a detailed discussion about the way MySQL matches users and pemissions.

这篇关于使用正确的凭据拒绝访问,这是怎么回事?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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