2

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

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

But the application said this A Database Error Occurred

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

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

1
  • I'm sure that there is a way to connect to remote database server. Are you providing correct username/password? Commented Jan 7, 2011 at 3:49

2 Answers 2

3

The server located at that IP address must be configured to allow remote MySQL connections, at least to port 3306 or whichever port MySQL has been configured to listen on.

Sign up to request clarification or add additional context in comments.

Comments

3

In addition to BoltClock's answer above, it may also be necessary to grant the sql user proper permissions to connect remotely to the database.

Assuming that you are using MySQL, here are two (depending on how you would like it configured) different ways of performing that operation.

A) Allow remote connections for sql_user from IP 192.168.0.200:

mysql> GRANT ALL ON database.* TO 'sql_user'@'192.168.0.200' IDENTIFIED BY 'PASSWORD';

B) Allow remote connections for sql_user from any IP:

mysql> GRANT ALL ON database.* TO 'sql_user'@'%' IDENTIFIED BY 'PASSWORD';

Once done, you also need to flush/reload the privileges:

mysql> FLUSH PRIVILEGES;

1 Comment

I'm having the same problem. I've tried the steps you mentioned. but still getting the same error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.