Codeigniter Error “Unable to connect to your datab

2020-07-13 09:33发布

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 !

8条回答
2楼-- · 2020-07-13 10:31

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?

查看更多
\"骚年 ilove
3楼-- · 2020-07-13 10:32

If you are facing this issue in shared hosting environment. Then i think you have to give the database credentials same as cpanel/hosting credentials.

$db['default']['hostname'] = "localhost";
$db['default']['username'] = "cpanel/hosting username"; 
$db['default']['password'] = "cpanel/hosting password";
$db['default']['database'] = "dbname";
查看更多
登录 后发表回答