Mysql – Accessing databases from different domains on same server

lampMySQLPHP

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?

Best Answer

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.

Related Topic