A Database Error Occurred! fixed by db_debug set t

2019-06-02 11:36发布

问题:

Hi I just want to clear the question in my mind. I got an error

   Unable to connect to your database server using the provided settings.
   Filename: core/Loader.php
   Line Number: 346

after reading some of issue about that error I try to set $db['default']['db_debug'] = TRUE; to $db['default']['db_debug'] = FALSE; and it works!

as I read this in manual of CI Database Configuration

db_debug - TRUE/FALSE (boolean) - Whether database errors should be displayed.

I want to know that does really fix the problem or hiding not the error, but if it only hiding it how come it works? I am worried that it may cause future problem.

same question exist here.

any information and ideas is big help and well appreciated.Many Thanks!

回答1:

Try to $db['default']['pconnect'] = TRUE; set to false rather than $db['default']['db_debug'] = TRUE;



回答2:

I found why. In my situation, database error because my mysql config in php.ini is not right.

CI works well after I set mysql config in php.ini, like this:

[Mysql]
mysql.default_socket = /tmp/mysql.sock

If you didn't configure php.ini, the default socket is /var/mysql/mysql.sock, please check it.

I also set $db['default']['db_debug] to FALSE before, it looks ok, but no. It's just hide the error of mysql config, when I test to read from tables of mysql, I got nothing and didn't know why nothing. So I debug it, i found because my mysql connection was not established. :(



回答3:

Its worked for me

$db['default']['pconnect'] = FALSE;