cross server MySQL question..
- RichL
-
RichL
- Member since: Apr. 2, 2000
- Offline.
-
- Forum Stats
- Member
- Level 05
- Blank Slate
Is there any way to connect to a MySQL database on seperate servers? Example: A site has a database with infomation another site needs to use (lets say they are partner sites)..they are both on completely different servers. If you used the same script the other site used..but say linked the include to http://www.site.com/includes/connect.inc.php..why doesnt it work? I tried it and got this:
Warning: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111) in http://www.site.com/admin/mysql_connect.inc on line 1
Warning: MySQL Connection Failed: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111) in http://www.site.com/admin/mysql_connect.inc on line 1
Can't connect to Database
I know its because they are on different servers...but im sure ive seen it done somewhere before! any ideas/help?
- aladinsane
-
aladinsane
- Member since: Jan. 17, 2000
- Offline.
-
- Forum Stats
- Member
- Level 21
- Blank Slate
At 8/29/01 06:41 PM, RichL wrote: Is there any way to connect to a MySQL database on seperate servers? Example: A site has a database with infomation another site needs to use (lets say they are partner sites)..they are both on completely different servers. If you used the same script the other site used..but say linked the include to http://www.site.com/includes/connect.inc.php..why doesnt it work? I tried it and got this:
Warning: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111) in http://www.site.com/admin/mysql_connect.inc on line 1
Warning: MySQL Connection Failed: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111) in http://www.site.com/admin/mysql_connect.inc on line 1
Can't connect to Database
I know its because they are on different servers...but im sure ive seen it done somewhere before! any ideas/help?
You can't the include function to include files from other servers, it's too much of a security risk. All you need to do is use the IP address or domain name of the server with the database on in your connect statement, ie - instead of 'localhost' use the address of the other server.
- RichL
-
RichL
- Member since: Apr. 2, 2000
- Offline.
-
- Forum Stats
- Member
- Level 05
- Blank Slate
You can't the include function to include files from other servers, it's too much of a security risk. All you need to do is use the IP address or domain name of the server with the database on in your connect statement, ie - instead of 'localhost' use the address of the other server.
Thanks,put the include file on my server..changed localhost to "www.site.com", and now it gives me THIS:
Warning: Host 'ns1.phenominet.com' is not allowed to connect to this MySQL server in /home/echeats/public_html/ads/mysql_connect.inc on line 6
Warning: MySQL Connection Failed: Host 'ns1.phenominet.com' is not allowed to connect to this MySQL server in /home/echeats/public_html/ads/mysql_connect.inc on line 6
Can't connect to Database
- liljim
-
liljim
- Member since: Dec. 16, 1999
- Offline.
-
- Send Private Message
- Browse All Posts (11,644)
- Block
-
- Forum Stats
- Staff
- Level 28
- Blank Slate
Umm, yeah. There are three tables in the basic MySQL setup:
Users, db, and I forget the other (been to the pub :D).
The users and db's have users (with usernames and passwords) that are allowed to access the db's and tables (with GRANT accesses set), together with host details. There's also the "nobody" user, who generally is allowed to select, insert, delete and update from your tables.
Unless you have root access, or your hosting company allows users outisde sites they host to connect to the db's, there's little you can do about it.
- RichL
-
RichL
- Member since: Apr. 2, 2000
- Offline.
-
- Forum Stats
- Member
- Level 05
- Blank Slate
Unless you have root access, or your hosting company allows users outisde sites they host to connect to the db's, there's little you can do about it.
bugger. theres no other magical way i can do this? :(
- liljim
-
liljim
- Member since: Dec. 16, 1999
- Offline.
-
- Send Private Message
- Browse All Posts (11,644)
- Block
-
- Forum Stats
- Staff
- Level 28
- Blank Slate
At 8/30/01 04:12 AM, RichL wrote: bugger. theres no other magical way i can do this? :(
As I said... I without having the ability to change MySQL permissions to allow multiple hosts to connect to your db, no. That'd be a massive security risk.
- aladinsane
-
aladinsane
- Member since: Jan. 17, 2000
- Offline.
-
- Forum Stats
- Member
- Level 21
- Blank Slate
At 8/30/01 05:46 AM, liljim wrote:At 8/30/01 04:12 AM, RichL wrote: bugger. theres no other magical way i can do this? :(As I said... I without having the ability to change MySQL permissions to allow multiple hosts to connect to your db, no. That'd be a massive security risk.
Yeah, sorry Jim's right. I always forget minor details like that, I'm so used to having root access :)
If you want to do it you will need to give the IP address of the site you want to connect FROM to the admin of the server you want to connect TO and get them to add records to the db, user and tables_priv tables on the database.
Only other option is to process the data locally on the server running the database and then put it on your site with an IFRAME or something...
- Pecos
-
Pecos
- Member since: Dec. 29, 1999
- Offline.
-
- Forum Stats
- Member
- Level 03
- Blank Slate
At 8/30/01 04:12 AM, RichL wrote:Unless you have root access, or your hosting company allows users outisde sites they host to connect to the db's, there's little you can do about it.bugger. theres no other magical way i can do this? :(
Create your own DB - a comma-delimited, flat, text file
- RichL
-
RichL
- Member since: Apr. 2, 2000
- Offline.
-
- Forum Stats
- Member
- Level 05
- Blank Slate
Very disappointing. Ah well- back to entering the data myself :(. thanks for your help guys!

