[英]how to connect hosted server database through local server using php?
i want to connect hosted server database through local server here is my code 我想通过本地服务器连接托管服务器数据库,这是我的代码
<?php
$con=mysql_connect("myserverDbHostname","mydatabaseUsername","Password");
if($con)
{
echo "connect";
mysql_select_db("DatabaseName");
else
{
echo "not connect";
}
?>
when i run this file in local server (xammp server) it could n't be connect i get 当我在本地服务器(xammp服务器)中运行此文件时,无法连接我得到
Warning: mysql_connect() [function.mysql-connect]: Can't connect to
MySQL server on
i get "not connect" response 我得到“不连接”响应
can any one guide me 谁能指导我
Thanks for advance. 感谢前进。
There a three things you need to connect to a remote database: 连接到远程数据库需要完成三件事:
Virtual all hosting companies close port 3306 on the firewall, and do not allow direct remote access. 虚拟所有托管公司都关闭防火墙上的端口3306,并且不允许直接远程访问。 And even if they do, you won't get privileges to connect to a database.
即使他们这样做,您也不会获得连接数据库的特权。
Only if the remote database is in your LAN, or you are using a VPS with root access you can configure things to make a remote connection. 仅当远程数据库位于您的LAN中或使用具有root访问权限的VPS时,您才可以配置内容以建立远程连接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.