[英]how to connect to mysql on host on another computer on network
For 对于
$conn = mysql_connect("192.168.0.235", "root", "") or
die("Could not connect: " . mysql_error());
mysql_select_db("crossdomaintest");
$result = mysql_query("SELECT * FROM testing");
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
echo $row[1].$row[2].$row[3]."<br/>";
}
mysql_free_result($result);
I am getting 我正进入(状态
Warning: mysql_connect() [function.mysql-connect]: Host '192.168.0.167' is not allowed to connect to this MySQL server in /var/www/test.php on line 3 Could not connect: Host '192.168.0.167' is not allowed to connect to this MySQL server
警告:mysql_connect()[function.mysql-connect]:在第3行的/var/www/test.php中,不允许主机'192.168.0.167'连接到该MySQL服务器无法连接:主机'192.168.0.167'不允许连接到该MySQL服务器
And my IP is 192.168.0.168
and I am using LAMP
on Ubuntu 10.10
and 192.168.0.235
is using XAMPP on windows 7
i can access all sites on ...235
but not access database from my local-server. 我的IP是
192.168.0.168
,我在Ubuntu 10.10
上使用LAMP
,而192.168.0.235
在windows 7
上使用XAMPP,我可以访问...235
上的所有站点,但不能从本地服务器访问数据库。
Any ideas? 有任何想法吗?
it's not about "how to connect". 这与“如何连接”无关。 connecting would be all the same.
连接将是相同的。
it's about how to setup remote server to allow connections from your IP. 关于如何设置远程服务器以允许来自IP的连接。
do you have root privileges on the db server on 192.168.0.235? 在192.168.0.235的数据库服务器上具有root特权吗? if so, you have to run appropriate GRANT PRIVILEGES query on it.
如果是这样,则必须对其运行适当的GRANT PRIVILEGES查询。
If not - ask a db admin to do that 如果没有,请询问数据库管理员
I'd also advise not to use root user to access remote database. 我也建议不要使用root用户访问远程数据库。 Better create another user and give him appropriate privileges
更好地创建另一个用户并给他适当的特权
Did you change to root user access the host "%" ? 您是否更改为以root用户身份访问主机“%” ?
Sorry for my english i'm french. 对不起,我的英语我是法语。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.