Welcome to WebmasterWorld Guest from 23.20.221.93

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Is it possible to use one MySQL DB by 2+ sites?

Newbie question...

     
2:57 pm on Aug 10, 2004 (gmt 0)

Junior Member

10+ Year Member

joined:Feb 10, 2003
posts:161
votes: 0


Is it possible to use one MySQL DB by 2+ sites in one hosting account (CPanel, reseller)?
If it's possible what should i do and how should i connect to DB?
Tnanks in advance.
4:05 pm on Aug 10, 2004 (gmt 0)

Administrator

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 24, 2001
posts:15755
votes: 0


If they are in the same account does that mean they both have access to the same db? If you log into your site with ftp and they are both in the same area, then I would think you could use the same mysql_connect data in each site and it should work.

The best advice is to try it out. :)

Just use the same user/pass and then try connecting to mysql.

4:26 pm on Aug 10, 2004 (gmt 0)

Full Member

10+ Year Member

joined:June 6, 2003
posts:211
votes: 0


even if the accounts are on different servers, as long as mysql can be connected to by a remote machine, it should not be an issue
4:36 pm on Aug 10, 2004 (gmt 0)

Junior Member

10+ Year Member

joined:Feb 10, 2003
posts:161
votes: 0


Thanks!
Should i use 'localhost' or something else?
4:36 pm on Aug 10, 2004 (gmt 0)

Full Member

10+ Year Member

joined:June 6, 2003
posts:211
votes: 0


the remote site would have to use the ip address of the sql database server. if both are on the same machine, use localhost.
4:48 pm on Aug 10, 2004 (gmt 0)

Junior Member

10+ Year Member

joined:Feb 10, 2003
posts:161
votes: 0


Thanks a lot!
5:25 pm on Aug 11, 2004 (gmt 0)

Moderator

WebmasterWorld Administrator ergophobe is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Apr 25, 2002
posts:8298
votes: 142


Also, if the sites are not sharing a set of tables (in which case, why two sites?), come up with a prefix schema for your tables. So you have tables

site1_users
site1_other_table

site2_users
site2_other table

11:59 pm on Aug 29, 2004 (gmt 0)

Full Member

10+ Year Member

joined:June 6, 2003
posts:211
votes: 0


I'd rather keep everything the same, and have the connection random which server it uses.