Ian
Ian

Reputation: 39

remote mysql connection using php

I am trying to log in using php script to a remote mysql DB.

The DB is open for remote connections. I can connect using mysql admininstrator prog or openoffice (ODBC) from my home PC.

I have tried running the script on two different accounts on the some web host as each other but different from the DB without success.

Also, the script wont connect from one of those two accounts to DB on the other.

It seems that the php setup on the server hosting the script wll not allow connect to a remote DB, even if the DB is hosted with the same webhost. The script just times out.

Any ideas

Upvotes: 3

Views: 409

Answers (3)

RTB
RTB

Reputation: 5823

i'm not sure, but there is something called SQL safe mode. Then 'localhost:3306' is always used as the server to connect with.

@Daniel is right: You should contact your host, or check if this config value is set in you phpinfo.

Upvotes: 1

Dejan Marjanović
Dejan Marjanović

Reputation: 19380

Try SQLyog.

With it, you can use HTTP Tunneling, you basically copy one PHP file to your folder root and use database credentials.

enter image description here

You can also try doing the same with Putty http://oldsite.precedence.co.uk/nc/putty.html

I'm sure there is free software with the same tunneling functionality as SQLyog.

Upvotes: 5

symcbean
symcbean

Reputation: 48357

The DB is open for remote connections

Then you've got big security problems. Databases should never be exposed directly on the internet. Indeed, ISR a recent vulnerability affecting MySQL mariaDB and Perconawhich could easily be exploited.

That you can connect from home suggests that there is no host whitelist, but simply that the machines you are failing to connect from have routing issues or the firewall is configured to prevent such access. It's very unlikely to be anything to do with the PHP config.

Once you have disabled remote access to the target DB, the right way to solve the problem is by using a VPN or an SSL port tunnel.

Upvotes: 2

Related Questions