简体   繁体   English

如何连接到网络上另一台计算机上主机上的mysql

[英]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.235windows 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. 对不起,我的英语我是法语。

  • Cosmik. Cosmik。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将 docker 容器上的 php 脚本与网络主机连接,同时在网络主机上使用 mysql Z05B6053C41A2130AFD68BDAB3E 容器 - How connect a php script on docker container with network host, with a mysql docker container also on network host 如何使用PDO在另一个主机中连接mysql db? - How to connect mysql db in another host using PDO? 连接到同一网络上另一台PC上的mysql数据库 - Connect to a mysql db on another pc on the same network 如何使用另一台计算机连接到mysql localhost数据库 - How to connect to mysql localhost database with a different computer 无法从网络内的另一台计算机访问Laravel angularJS本地主机 - Laravel angularJS local host cannot be accesed from another computer inside my network 如何将我的MySQL数据库传输到另一台计算机? - How to transfer my MySQL database to another computer? 如何从另一台计算机或设备访问XAMPP虚拟主机? - How to access XAMPP virtual host from another computer or device? 如何在docker容器中连接我的主机mysql? - How to connect my host mysql in docker container? 使用 XAMPP 通过 MySQL 和 phpMyAdmin 从本地网络内的另一台计算机访问本地网站 - Accessing a local website from another computer inside the local network using XAMPP through MySQL & phpMyAdmin php请求:警告:mysql_connect():php_network_getaddresses:getaddrinfo失败:此类主机未知 - php request: Warning: mysql_connect(): php_network_getaddresses: getaddrinfo failed: No such host is known
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM