Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql - connect to remote server using IP address

Tags:

php

mysql

I am using PHP and MySQL to make a database connection, the only change is that I am trying to access my remote server from my local computer using my server IP address.

mysql_connect("x.xx.xx.x","username","password") or die(mysql_error());

and the error I am getting is Unable to connect to the given host. The user has all privileges and rights.

like image 845
Frank Avatar asked Oct 13 '11 13:10

Frank


People also ask

How do I access a remote database?

Log in to cPanel. Under the Databases section, click on the Remote MySQL® icon. On the Remote MySQL® page, enter the connecting IP address, then click Add Host.

What tool is used to connect to a MySQL server remotely?

Using MySQL Workbench to access your remote MySQL database through an SSH tunnel is a simple and secure way to manage your databases from the comfort of your local computer.


1 Answers

Most default installs of MySQL only listen to the local machine.

Look for the bind-address setting in my.cnf on the server, and make sure it's listening on the IP address you're targetting. You may also need to ensure skip-networking isn't switched on!

Alternatively (and less securely!) the following will set it up to listen on all addresses - local and remote:

bind-address = 0.0.0.0
like image 52
Jeremy Smyth Avatar answered Sep 24 '22 07:09

Jeremy Smyth