简体   繁体   English

php mysql从另一台服务器连接数据库

[英]php mysql Connect Database from another server

Connect Database from another server in mysql and php I use this : 从另一台服务器在mysql和php中连接数据库,我使用以下命令:

<?php
$db = mysql_connect("mysite.com", "theusername", "proud");
mysql_select_db("theotherserverDB",$db);

?>

need to Fix? 需要修复?

<?php

mysql_connect("mysite.com:3306", "admin", "1admin") or die(mysql_error());
echo "Connected to MySQL<br />";

?>

Just run it and see if it works. 只需运行它,看看它是否有效。

Before making the connection.. you should reserve the domain or IP address of the server you are about to communicate from.... 建立连接之前..您应保留要与之通信的服务器的域或IP地址。

If you are using cpanel you can do this by clicking on remote MYSQL under databases. 如果使用的是cpanel,则可以通过单击数据库下的远程MYSQL来完成。

Good luck... 祝好运...

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM