Reputation: 59
I am trying to connect to MySql database remotely using the following script on port 3307
$username="user";
$password="pass";
$database="db";
mysql_connect('ccline.dyndns.info:3307',$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
but unable to connect. I was using this same script on a db using 3306. What am I missing??
Upvotes: 0
Views: 33890
Reputation: 5739
First: You miss to use the mysqli_* functions instead of the mysql_* function For more informations take a look here
To your question: I bet, on your mysql_server ccline.dyndns.info the port 3306 / 3307 is not open ... or the server is configurated not to listen on request wich are not equal localhost
So if you use the php-script on the same machine as the mysql server, connect by localhost:3307 .....
Upvotes: 1
Reputation: 21856
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. 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.
Upvotes: 1