Welcome Guest, Not a member yet? Register   Sign In
How to connect database using one not in localhost
#1

[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
#2

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

[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
#4

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

[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'] = "Grp@dm1nroot";
$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";
#6

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

[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'] = "Grp@dm1nroot";
$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";
#8

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

[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";
#10

[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




Theme © iAndrew 2016 - Forum software by © MyBB