CodeIgniter Forums
How to connect database using one not in localhost - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: How to connect database using one not in localhost (/thread-37337.html)

Pages: 1 2


How to connect database using one not in localhost - El Forum - 01-06-2011

[eluser]Miftah Zein[/eluser]
[quote author="Atharva" date="1294327917"]
Code:
$db['server']['hostname'] = "192.168.0.120";

$active_group = "server";
[/quote]

Either in server or local in $active_group, oddly enough i still get error message

Maybe i have to hack the core database file in codeigniter?


How to connect database using one not in localhost - El Forum - 01-06-2011

[eluser]Atharva[/eluser]
No , this is related with you db settings. I was bit confused about your testing environment. Change
Code:
$active_group = "local";
and
Code:
$db['local']['hostname'] = "192.168.0.120";
Can you access phpmyadmin of 192.168.0.120 from your machine?


How to connect database using one not in localhost - El Forum - 01-06-2011

[eluser]Miftah Zein[/eluser]
yes i can access phpmyadmin, maybe the problem lies in database driver??
when i change hostname to localhost, everithing is ok. but if i set it to 192.168.0.120 i got error again

sorry for bothering you again :-)


How to connect database using one not in localhost - El Forum - 01-06-2011

[eluser]Atharva[/eluser]
so 192.168.0.120 is IP of your own machine? Can you access like http://192.168.0.120/phpmyadmin ? Also, you can try to create a new user on 192.168.0.120 server, and then use that username and password in database.php and see if that works?


How to connect database using one not in localhost - El Forum - 01-06-2011

[eluser]Victor Michnowicz[/eluser]
Sometimes you need to put the port in there as well. Assuming MySQL connects on port 3307:

Code:
$db['local']['hostname'] = "192.168.0.120:3307";