mysql - mysql '用户'user'@'localhost'的访问被拒绝(使用密码:YES)'
问题描述
我注意到奇怪的事情。我在 php+mysql 上有用户 jewwishl 的网站。用户 jewwish 可以从 Internet 访问 mysql:
mysql> select user,host,authentication_string from mysql.user;
+------------------+-----------+-------------------------------------------+
| user | host | authentication_string |
+------------------+-----------+-------------------------------------------+
| root | localhost | *PASSWORD |
| mysql.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| debian-sys-maint | localhost | *PASSWORD |
| coremgr | localhost | *PASSWORD |
| phpmyadmin | localhost | *PASSWORD |
| roundcube | localhost | *PASSWORD |
| mysql.session | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| jewwish | localhost | *PASSWORD |
| jewwish | % | *PASSWORD |
| jewwishl | localhost | *PASSWORD |
+------------------+-----------+-------------------------------------------+
10 rows in set (0.01 sec)
我想关闭它。我在 ispmanager 中禁止用户 jewwish 访问互联网,所以我得到了
mysql> select user,host,authentication_string from mysql.user;
+------------------+-----------+-------------------------------------------+
| user | host | authentication_string |
+------------------+-----------+-------------------------------------------+
| root | localhost | *PASSWORD |
| mysql.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| debian-sys-maint | localhost | *PASSWORD |
| coremgr | localhost | *PASSWORD |
| phpmyadmin | localhost | *PASSWORD |
| roundcube | localhost | *PASSWORD |
| mysql.session | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| jewwish | localhost | *PASSWORD |
| jewwishl | localhost | *PASSWORD |
+------------------+-----------+-------------------------------------------+
9 rows in set (0.00 sec)
但如果我这样做,我会收到错误“无效的授权规范:1045 Access denied for user 'jewwish'@'localhost' (using password: YES)”。可能是什么原因?'jewwish'@'%' 与 'jewwishl'@'localhost' 的关系是什么?
UPD 这里是连接代码:
define("DB_NAME", "jewwish");
define("DB_USER", "jewwishl");
define("DB_PASS", "password");
define("DB_HOST", "localhost");
...
$dbConnection = new PDO('mysql:dbname='.DB_NAME.';host='.DB_HOST.';charset=utf8', DB_USER, DB_PASS);
解决方案
推荐阅读
- wordpress - 无法获取自定义分类存档页面以显示帖子
- android - 使用 WorkManager 时是否可以在通知区域显示进度条 - 像 WhatsApp 数据同步
- c - 未声明的错误结构(在此函数中首次使用)
- c - 没有“Windows 安全警报”的网络程序
- mongodb - 如何找到具有多个参数.net core + mongodb的任何匹配记录
- ionic-framework - 未列出离子低功耗蓝牙设备
- javascript - 如何从科尔多瓦应用程序向服务器发送大量数据
- python - 使用 python 将图像放置到网络摄像头源 - windows 中的 pygame
- css - 使用 CSS 无限滚动图像
- ajax - 来自客户端的并行异步 Ajax 调用