PDA

View Full Version : Connecting to MySQL on a different server


tonyk
09-02-2002, 06:25 PM
I'm working with a PHP/MySQL shopping application (oscommerce) and I am running the application with Database on one server (server1.com) and would like to run the admin and checkout portions of the application on a second secure server (server2.com).

I am able to reference the MySQL database on one server from the secure server using PHP and a standard connection method:

//Connecting to the database
$con = mysql_connect("server1.com:Port","testuser","password") or die ("Couldn't connect to server");

//Specifying the database
$db = mysql_select_db("database", $con) or die ("Couldn't connect to database");

But I get the following error, when it tries to authenticate the user:

Mozilla/4.0 (compatible; MSIE 5.5; Windows 98; T312461)
Warning: MySQL Connection Failed: Access denied for user: 'testuser@server2.com' (Using password: YES) in /usr/local/htdocs/lakeview/test1.php on line 14
Couldn't connect to server

Rather than trying to log testuser into MySQL on server1.com, it is trying to login testuser@server2.com...who is obviously not a valid user for that database on server1.com.

Is there anyway to prevent PHP from passing testuser@server2.com as the login user? I just need to be able to login testuser with not @ or identification of the server the request is originating from.

Thanks in advance for any advice on how to do this.

imported_Gryphon
09-03-2002, 12:43 AM
Your host as the ability to only allow localhost connections. You may not be able to connect remotely.

Uranium-235
09-03-2002, 01:05 PM
Same thing I was thinking gryph, GSI dosent allow outside connections eather, actually now that I think about no one I host with allows outside connections. It's too risky, someone could write a brute force script (or app) and run it for days attempting to get a correct hit on usrname and password, and eventually get it