Try to connect with php-mysqli to external mysql database (non-cpanel)
Hi,
I'am trying to connect with a php script to connect to an external mysql database.
But i think cpanel/whm is blocking somewhere external connections.
Things that i already have done:
if i run in ssh:
mysql -u sql_username -h sql_ipadres -P 7999 -p i have successfully connection to external database. (so firewall accept outgoing connection port 7999)
If i run on php file:
[CODE=php]$conn = new mysqli("$ip_externhost","$user","$password","$DB","$port");
I get an error
I'am 100% that the credentials are right so that is not the problem. So something change the external ip-adres to local-ipadres. So i think i have to enable something, but i don't know where? Is it possible that mysqli can't connect to a external DB? The script is running on PHP 7.2
I get an error
Failed to connect to MySQL: Access denied for user '$user'@'localipadres' (using password: YES)I'am 100% that the credentials are right so that is not the problem. So something change the external ip-adres to local-ipadres. So i think i have to enable something, but i don't know where? Is it possible that mysqli can't connect to a external DB? The script is running on PHP 7.2
-
Hello, if you're trying to connect externally from a cPanel to server to another server running a MySQL, make sure the server firewall allows external connections. For example, if you're using CSF, add port 3309 to TCP_OUT. If you don't have access to CSF, ask your host or whoever manages your server to check and make that change for you. 0
Please sign in to leave a comment.
Comments
2 comments