Welcome Guest, Not a member yet? Register   Sign In
How can I connect databse from one domain to another domain?

Hi all,

I have two domain like www.one.com and www.two.com
I want to access mysql database from one domain to another domain.
Is it possible? If it is possible how do i need to setup?

please advice me.

Question no 1:
Are both of them hosted on the same account/virtual server/box?

I have two options.

one category is different account.

one category is same account.

pls give for two options.

[eluser]Yorick Peterse[/eluser]
You would connect to this server the same way as you normally would. I'm not sure if CI supports a socket based connection, but if you're running a plain MySQL server you'll just have to enter the details as you normally would do and you're done.

For example:

$db['default']['hostname'] = "domain2.com";
$db['default']['username'] = "username";
$db['default']['password'] = "passwprd";
$db['default']['database'] = "database";
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = FALSE;
$db['default']['cache_on'] = TRUE;
$db['default']['cachedir'] = "application/cache/database";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";


This setup I have done for which domain is running currently.

After Login my page I want to create report . So I need to retrieve data from both table as well as from both domain database .

easy ..
#system/application/config/database.php #@ www.one.com

$db['default']['hostname'] = "localhost";
$db['default']['username'] = "root";
$db['default']['password'] = "";
$db['default']['database'] = "dbname";
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";

when you need to connect to www.two.com
$group_name['hostname'] = "remote.domain2.com";
$group_name['username'] = "remote_user";
$group_name['password'] = "remote_pass";
$group_name['database'] = "db_name";
$group_name['dbdriver'] = "mysql";
$group_name['dbprefix'] = "";
$group_name['pconnect'] = TRUE;
$group_name['db_debug'] = TRUE;
$group_name['cache_on'] = FALSE;
$group_name['cachedir'] = "";
$group_name['char_set'] = "utf8";
$group_name['dbcollat'] = "utf8_general_ci";

$this->load->database('group_name'); #connecting to www.two.com database

.. of course you need to provide remote account at www.two.com

Theme © iAndrew 2016 - Forum software by © MyBB