Connect to an online MySQL database from localhost

后端 未结 5 2018
旧时难觅i
旧时难觅i 2021-01-19 02:06

I am trying to connect to my MySQL database on my online server via PHP on my localhost.

$con = mysql_connect(\"$hostname\", \"$username\", \"$password\");
i         


        
5条回答
  •  广开言路
    2021-01-19 02:51

    Your code is ok.

    As others stated the MySQL server has to allow connections from remote machines. Also make sure your provider's firewall isn't blocking the request and double check the hostname, because it may differ from the one you use on your server.

    If you didn't set up your server yourself, you'll probably have to speak with th user support of your hoster, because they have the permissions to change settings and more accurate info on this topic.

提交回复
热议问题