【发布时间】:2015-12-13 09:51:49
【问题描述】:
先说一些细节:: 在 Ubuntu 14.10 LTS 上运行 MySQL 5.6,Apache 作为网络服务器。 服务器位于路由器后面,因此端口 80 和 3306 被转发并且正常。 网络服务器运行良好。
MySQL 用户列表:
mysql> select user, host from mysql.user;
+------------------+-------------------+
| user | host |
+------------------+-------------------+
| userA | % |
| root | 127.0.0.1 |
| debian-sys-maint | localhost |
| phpmyadmin | localhost |
| root | localhost |
| userA | localhost |
| root | elite81 |
+------------------+-------------------+
my.cnf 文件:
`[客户端]
port = 3306
socket = /var/run/mysqld/mysqld.sock
# Here is entries for some specific programs
# The following values assume you have at least 32M ram
# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 0.0.0.0
`
问题:: 只有“root”可以访问 MySQL 数据库。我想使用“userA”进行访问,但出现以下错误代码:
A) 当php代码中的host值为:服务器的外部IP地址时
Warning: mysqli::mysqli(): (28000/1045): Access denied for user 'userA'@'router.asus.com' (using password: YES)
B) 当主机值为:127.0.0.1
Warning: mysqli::mysqli(): (28000/1045): Access denied for user 'userA'@'localhost' (using password: YES)
尝试纠正此问题失败:
哈希绑定地址 / 将绑定地址更改为 192.168.1.87(本地 IP 地址)/ 将绑定地址更改为外部 IP 地址 /
还尝试在网络内连接 - 不起作用/
也完成了 FLUSH PRIVILEGES;在 MySQL 中。
在网上浏览了几篇相关的帖子,但没有解决! :-( 需要帮助。
另外,我有一个问题。 当网络服务器与 MySQL 服务器在同一台机器上运行时,php 连接文件中的主机应该是什么?
【问题讨论】:
-
附加信息:我可以在机器上连接为
mysql -u userA -p -hlocalhost,但不能连接为mysql -u userA -p -h11.11.11.11 -
删除
userA@%进行检查:没有用