PHP - connecting to mysql database from different servers

I am trying to connect to the mysql database from another server to the one on which the database is located, but I get an error.

I assume this might be due to remote permissions. Can I change this or do I need my hosting company to do this?

<?php $con = mysql_connect("mysql4-remote.hosting.net","myadmin","password123"); if (!$con) { die('Could not connect: ' . mysql_error()); } ?> 

Can't connect to MySQL server on 'mysql4-remote.hosting.net' (10060)PHP Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'mysql4-remote.hosting.net' (10060) in D:\websites\abc123\www\test.php on line 2

+4
source share
2 answers

I would say that your credentials or network settings are incorrect: See this post for further assistance: http://wiki.answers.com/Q/What_does_MySQL_error_number_10060_mean

If you do not have access from tunneling from the outside, here is an example:

 $connection = ssh2_connect('SERVER IP', 22); ssh2_auth_password($connection, 'username', 'password'); $tunnel = ssh2_tunnel($connection, 'DESTINATION IP', 3307); $db = new mysqli_connect('127.0.0.1', 'DB_USERNAME', 'DB_PASSWORD', 'dbname', 3307, $tunnel) or die ('Fail: '.mysql_error()); 
+6
source

You must grant permission to the remote user by inserting the specific IP address of the remote computer or wildcards into the USER table in mysql.

This link will help you. Press here

+1
source

All Articles