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]
Someone help me, please

I want to develop application that my database is not in the localhost, like this

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

But the application said this

Code:
A Database Error Occurred

Unable to connect to your database server using the provided settings.

I've googled it but i got nothing.

can codeigniter using some server database instead of just localhost ?? or maybe something missing?

Thanks before


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

[eluser]Atharva[/eluser]
check your username, password and database name. Yes, codeIgniter can connect to db located on any other server.


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

[eluser]Miftah Zein[/eluser]
[quote author="Atharva" date="1294324519"]check your username, password and database name. Yes, codeIgniter can connect to db located on any other server.[/quote]

Thanks Atharva for the answer but my app is still the same.
I've set server, username, and password with its config.
I'm still dont know how to do


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

[eluser]Atharva[/eluser]
Can you post your database.php db connection code here?


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

[eluser]Miftah Zein[/eluser]
[quote author="Atharva" date="1294325826"]Can you post your database.php db connection code here?[/quote]

it look like this

Code:
File: database.php

$active_group = "local";
$active_record = TRUE;

$db['server']['hostname'] = "localhost";
$db['server']['username'] = "grpuc621_dbroot";
$db['server']['password'] = "[email protected]";
$db['server']['database'] = "grpuc621_landscape";

$db['local']['hostname'] = "localhost";
$db['local']['username'] = "root";
$db['local']['password'] = "";
$db['local']['database'] = "landscape";

$db["$active_group"]['dbdriver'] = "mysql";
$db["$active_group"]['dbprefix'] = "";
$db["$active_group"]['pconnect'] = TRUE;
$db["$active_group"]['db_debug'] = TRUE;
$db["$active_group"]['cache_on'] = FALSE;
$db["$active_group"]['cachedir'] = "";
$db["$active_group"]['char_set'] = "utf8";
$db["$active_group"]['dbcollat'] = "utf8_general_ci";



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

[eluser]Atharva[/eluser]
So when you are getting this error? On your localhost or on your development server?


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

[eluser]Miftah Zein[/eluser]
[quote author="Atharva" date="1294327469"]So when you are getting this error? On your localhost or on your development server?[/quote]

I'm very sorry, recently i set back it to localhost on 192.168.0.112

For file that got wrong is like this

Code:
$active_group = "local";
$active_record = TRUE;

$db['server']['hostname'] = "localhost";
$db['server']['username'] = "grpuc621_dbroot";
$db['server']['password'] = "[email protected]";
$db['server']['database'] = "grpuc621_landscape";

$db['local']['hostname'] = "192.168.0.120";
$db['local']['username'] = "root";
$db['local']['password'] = "";
$db['local']['database'] = "landscape";

$db["$active_group"]['dbdriver'] = "mysql";
$db["$active_group"]['dbprefix'] = "";
$db["$active_group"]['pconnect'] = TRUE;
$db["$active_group"]['db_debug'] = TRUE;
$db["$active_group"]['cache_on'] = FALSE;
$db["$active_group"]['cachedir'] = "";
$db["$active_group"]['char_set'] = "utf8";
$db["$active_group"]['dbcollat'] = "utf8_general_ci";



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

[eluser]Miftah Zein[/eluser]
I got error on development server when using 192.168.0.120 config


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

[eluser]Atharva[/eluser]
Ok, so assuming that host 192.168.0.120 exists, you need to make sure the username root exists with no password. You can test it by trying to login into phpmyadmin of that server. Click on privileges tab, and you will see the users.

Edit: This was posted before reading your previous comment. So it should be
Code:
$db['server']['hostname'] = "192.168.0.120";

$active_group = "server";



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

[eluser]Miftah Zein[/eluser]
Yes it is, there is user named root with no password

I've attach image in its phpmyadmin on 192.168.0.120