search

Home  >  Q&A  >  body text

How to configure mysql remote php external network link database

$con = mysql_connect("47.107.159.50:3306","root","root");

After using phpstudy to configure the mysql database on the Alibaba Cloud host, the php code is linked to the database. How to fill in the database address

、‘()’、‘()’2228 days ago1308

reply all(3)I'll reply

  • 崇拜

    崇拜2019-02-28 14:26:31

    Oh oh oh oh oh oh

    reply
    0
  • 刘宁

    刘宁2019-01-23 09:49:19

    $host = '47.107.159.50';

    $port = 3306;

    $user = 'root';

    $password = 'root';

    $db_name = '表名';

    if(!$con = mysqli_connect($host,$user,$password,$db_name,$port)){

    echo "can not connect to databases";

    }else{

    if($db_name != ''){

    //选择数据库

    if(!mysqli_select_db($con,$db_name)){

    echo "can not select database" . $db_name;

    return false;

    }

    }

    }

    //发送语句

    mysqli_query($con,"SET NAMES 'UTF8'");


    reply
    1
  • Cancelreply