Web Hosting Talk







View Full Version : Connecting to MYSQL on other server


andy18
11-14-2002, 06:59 PM
Hello,

I want to be able to connect to a MySQL database on another server. I think i can do this using ADO's RDS facility but what would the connection string be? Also what is the easiest way to make this information about another database secure, because if using RDS the database information (eg Username and password) is made public to the user.


Any idea on this ?



Thanks.



Andy

jtrovato
11-14-2002, 07:36 PM
what is connecting to the server.. another server running PHP , Perl, Pascal...

andy18
11-14-2002, 07:38 PM
ASP

jtrovato
11-14-2002, 07:44 PM
not sure lol sorry, I know with PHP I do it all the time. I connect to a remote server and use it for backup...

Good luck I wish I could help

MoSupaFly
11-14-2002, 07:48 PM
I'm curious what you use as a connection string for a mySQL DB on the same server as the web server then?

Are you using an ODBC driver? OLEDB provider? DSN?

andy18
11-18-2002, 04:37 PM
Hello,

Ok.I have created a ODBC DSN on the server and when I try to connect to the another server database ,I got the following error :

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[TCX][MyODBC]Access denied for user: username@209.197.251.20' (Using password: YES)

Any idea I can solve this?

Below is my connection string :

<%'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using DSN connection
adoCon.Open "DSN=DSNNAME"



Andy

MoSupaFly
11-18-2002, 06:52 PM
Well the ASP code is fine.

When you created the DSN on the server, did you click on the 'test connection' button just to make sure the DSN was able to connect?

From the looks of it... your MySQL DB doesn't recognize the username and/or password you're using to connect. Did you 'GRANT' access to the DB for the username/pwd you have in the DSN?

andy18
11-18-2002, 07:02 PM
MoSupaFly,

thanks for the favourable reply.

I try to search for the "Test DNS connection",can't find it.





Andy

achost_ca
11-18-2002, 07:31 PM
i have a feeling that the problem is that your user that you connect with is only a 'localhost' user. If you can change it to % instead of localhost that will fix it if that is the problem.

MoSupaFly
11-18-2002, 08:54 PM
I just checked and the button you're looking for is labeled 'Test Data Source' and it'll be on the dialog box that comes up after you've gone through the DSN wizard.

I'm primarily an ASP/MSSQL developer so my knowledge of MySQL is limited. So I can't offer much help beyond what I've told you so far.

If anything... check this link I've found for you:

http://www.mysql.com/products/myodbc/faq.html#Remote_connection

That should take you to a FAQ on the MySQL site that kinda explains what I was talking about with the 'GRANT' command.

andy18
11-19-2002, 10:36 AM
thanks!!:D

MoSupaFly
11-19-2002, 03:11 PM
no problem. Hope you get things figured out. :)

andy18
11-20-2002, 03:36 PM
still getting the same error message....:bawling:

MoSupaFly
11-20-2002, 04:14 PM
Hmm... dunno what to tell ya then. :(

Did you try achost_ca's advise?

andy18
11-20-2002, 04:18 PM
yup..

I have changed it to %user instead of localhost..


Andy

MoSupaFly
11-20-2002, 05:38 PM
dunno... maybe this link will help ya :)

http://www.mysql.com/doc/en/Access_denied.html

ghost
11-20-2002, 08:55 PM
Originally posted by jtrovato
not sure lol sorry, I know with PHP I do it all the time. I connect to a remote server and use it for backup...

Good luck I wish I could help

I want to backup my datas on another server, I use PHP too, would you explain it?

andy18
11-22-2002, 03:40 PM
Hello,

I have checked thoroughly and found that the MYSQL host in the DSN is not working.I have change to the remote server IP address but when I try to connect, the DSN is still using the server original IP address rather than the remote server IP.

I think this might be the cause.


How can I make correction on this?




Thanks for your brilliant input.




Andy

MoSupaFly
11-22-2002, 04:00 PM
That's odd.

What if you just delete that DSN and recreate one from scratch with the correct IP?

andy18
11-22-2002, 04:07 PM
Tried that.


Still the same.....:confused:

MoSupaFly
11-22-2002, 05:27 PM
Hmmm... now that is odd.

What if you don't use a DSN at all and call the MyODBC driver directly with your connection string?