简体   繁体   中英

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

Try SQLyog .

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

在此输入图像描述

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.

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM