Hello, is it possible to use Drupal with a database that is in othe IP that is not localhost?How can you do it?

Thanks

Comments

sin’s picture

in settings.php edit database connection string and replace localhost with your remote database host. I successfully connected with a string like this:
$db_url = "mysql://username:password@my_very_remote_host.com/databasename";
try put your db host IP instead of my_very_remote_host.com...

ap’s picture

I assume all you need to do is supply the proper IP and/or URL in the settings.php file where the MySQL login settings are located. Try "sites/default/settings.php".

I have not ever done this personally but it should work.

hpk’s picture

You also need to add your site's IP in the list of hosts permitted to access the database on the database hosting server. However, I only tried doing this from my local system i.e. I wanted to replicate my website on my local machine with the database on the webserver. Apparently it worked but I couldn't access admin pages. In some forums it was said that this happens if you have caching on or are alloing too little memory for php (less then 8MB).

If soem one knows more about this, please elaborate.

Thanks.

hpk a.k.a. vikram
[De-centralizing the central issues]
http://hpk.co.in

Anonymous’s picture

It works ok for me remotely without changing caching or memory. Only it's quite slower on admin pages than I thought it should be.

vmevada102’s picture

as per yuor instructin i have created the new db cdetials in setting.php file

now how can i make the table view of my database .

for instance i have onq my sql database of address book with fields like,

Name;
address;
phone no;

database type: mysql

as per your ionstruction and oother information i have to paste the

db_set_active('mydb');

db_query('SELECT * FROM table_in_anotherdb');

//Switch back to the default connection when finished.
db_set_active('default');

but wehere i have to put this php code..in views or any other location..

please help me...how can i view the details of my mysql database

thanks in advance

please help me about it

mmilenkovic’s picture

You need to add server on the list in the settings.php file , and then call db_set_active('mydb');. It is easy check http://drupal.org/node/18429