Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a LAMP server - on there I have multiple domains. Each domain has its own user, db's, public_htmls/, etc.

I need to access Domain A's database from a web app on Domain B in php.

Currently I just use localhost as my host for all DB connections in my web apps - but now I need to access a DB under a different domain so that obviously won't work.

Not sure if there is server (apache/php/dns) configuration required which would make this question better suited for server fault.

Any ideas?

share|improve this question

migrated from stackoverflow.com May 13 '11 at 3:25

This question came from our site for professional and enthusiast programmers.

    
Do you experience any issue? Have you tried to do anything? "DB under a different domain so that obviously won't work" --- obviously it will work. –  zerkms May 11 '11 at 4:31
    
@zerkms: I see your point. Deleting comment –  Ex Umbris May 11 '11 at 4:34
    
@zerkms - yea, I'm an idiot. Thanks. –  bMon May 11 '11 at 4:35
    
@bMon: you would be if you did not get your mistake ;-) So you're just a newbie. –  zerkms May 11 '11 at 4:36

2 Answers 2

up vote 3 down vote accepted

If you only have one server, then localhost is still your local server. You only have one MySQL server for all your domains.

You simply need to specify a different database when you connect - you may still use localhost as the server.

share|improve this answer

According to my view the solution is very simple and for that you have to have the MySQL remote access and LAMP is managed by CPANEL and thus you or your service provider has to open the port for external connection. You can describe the specific ip address to connect only static ip address for security, static ip address would be your website ip address. After you open the port for connection then you can easily connect to the database of other domain whether it is on the same server or different server.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.