简体   繁体   中英

php mysql Connect Database from another server

Connect Database from another server in mysql and php I use this :

<?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....

If you are using cpanel you can do this by clicking on remote MYSQL under databases.

Good luck...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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