|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Connecting to MySQL on a different server
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 //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. |
|
#2
|
|||
|
|||
|
RE: Connecting to MySQL on a different server
What is happening is by design...the portion after the @ is the host you are connecting from. What you need to do is add a use in your database that corresponds to the user@hostname combo....
|
|
#3
|
|||
|
|||
|
RE: Connecting to MySQL on a different server
Try passing:
mysql_connect($server, user@server1.com, $pass); Otherwise, log on to the MySQL server and set the username to be test@% - this will allow any host and should resolve the problem. Have you ensured your password is correct as well - I only ask because the error resmbles the error you get with an incorrect password. |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > Connecting to MySQL on a different server |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|