Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter Error "Unable to connect to your database server using the provided settings"

When I trying upload this project on my domain m facing error "Unable to connect to your database server using the provided settings"

I have checked my config.php and database.php file and all the information are correct:

 $db['default']['hostname'] = "etc.com";
 $db['default']['username'] = "etc"; 
 $db['default']['password'] = "etc@etc";
 $db['default']['database'] = "visiting_link";
 $db['default']['dbdriver'] = "mysql";
 $db['default']['dbprefix'] = "";
 $db['default']['pconnect'] = TRUE;
 $db['default']['db_debug'] = TRUE;
 $db['default']['cache_on'] = FALSE;
 $db['default']['cachedir'] = "";
 $db['default']['char_set'] = "utf8";
 $db['default']['dbcollat'] = "utf8_general_ci"; 

Is any solution to that problem? please refer any helping material. I am using fileZilla.
Thanks !

like image 296
Noumi Avatar asked Mar 03 '12 09:03

Noumi


3 Answers

Setting "db_debug" to false solved my problem.

I'm using Snow Leopard.

EDIT: db_debug just obfuscated my direction. The solution in my case was just the mysql.sock reference path, as solved on this question: Warning: mysql_connect(): [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock) in

OS X use /tmp/mysql.sock, and by default php.ini is referencing /var/mysql/mysql.sock. Just creating a symlink solves the problem:

sudo mkdir -p /var/mysql/ && cd /var/mysql/
sudo ln -s /tmp/mysql.sock ./mysql.sock
like image 163
Endel Dreyer Avatar answered Oct 04 '22 07:10

Endel Dreyer


Try setting the 'dbdriver' to 'mysqli'

$db['default']['dbdriver'] = "mysqli";

It's the MySQL Improved Extension (http://php.net/manual/en/book.mysqli.php) and your server may be set to use this rather than the standard MySQL extension.

I've seen this happen a few times when all other settings are correct, as the connection will fail if the wrong driver is selected.

like image 34
Dan Murfitt Avatar answered Oct 04 '22 06:10

Dan Murfitt


If the database settings are correct, than something is wrong anywhere else:

  • maybe the database does not accept connections from anywhere; in this case, you need to allow connections from your 'username'@'server IP'

  • maybe PHP or the server itself is not allowing the connection, due to a php.ini setting, a firewall, or something else

Back to the CI DB settings, you need to be sure they are correct. Are you sure the "hostname" is correct?

like image 26
J. Bruni Avatar answered Oct 04 '22 05:10

J. Bruni