3

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

2
  • 5
    i would contact your web host. Commented Jul 15, 2012 at 20:49
  • It might very well be that from a security perspective outgoing connections are blocked, see Daniel White's comment. Commented Jul 15, 2012 at 20:51

3 Answers 3

5

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.

Sign up to request clarification or add additional context in comments.

Comments

2

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.

2 Comments

The remote connections are actually very useful thing. You can use one database for multiple applications, what is very useful, though. Of course it's dangerous, but if you configure your settings properly (whitelist, on the first place), then there is no danger for you.
1

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.

3 Comments

I am waiting for hosting co to get back to me, but in meantime I have checked that sql.safe mode is off.
A workarround would be creating your own API in php on the mysql server. So the server that physically contains the mysql server you want to connect to should contain the api code. From other php server you can then make Curl requests using some kind of acces token.
@lan If my anwser helped please accept it so others can learn form it. If not how can i help you further?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.