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

When I try to load this project in my domain m, I encounter the error "Unable to connect to your database server using the provided settings"

I checked the config.php file and database.php and all the information is 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 there any solution to this problem? Please refer to any supporting material. I am using fileZilla.
Thank!

+5
source share
8 answers

Setting "db_debug" to false solved my problem.

I am using Snow Leopard.

EDIT: db_debug . mysql.sock, : : mysql_connect(): [2002] ( unix:///tmp/mysql.sock)

OS X /tmp/mysql.sock, php.ini /var/mysql/mysql.sock. symlink :

sudo mkdir -p /var/mysql/ && cd /var/mysql/
sudo ln -s /tmp/mysql.sock ./mysql.sock
+14

'dbdriver' 'mysqli'

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

MySQL (http://php.net/manual/en/book.mysqli.php), , MySQL.

, , , , .

+3

, - :

  • , ; " " @ "IP- "

  • , PHP - php.ini, - .

CI DB, , . , " " ?

+2

codeigniter 3, php. , php, codeigniter .

, , /config/database.php

$active_group = 'default';
$query_builder = TRUE;

$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'localhost',
    'username' => 'root',
    'password' => '',
    'database' => 'db_bdtimes', // your database name
    'dbdriver' => 'mysqli',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);
+1

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

0

. , , cpanel/hosting.

$db['default']['hostname'] = "localhost";
$db['default']['username'] = "cpanel/hosting username"; 
$db['default']['password'] = "cpanel/hosting password";
$db['default']['database'] = "dbname";
0

CMS , localhost TRUE. database.php :

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

Also CHECK if this line matches the setup of your server database (also for all tables):

$db['default']['dbcollat'] = "utf8_general_ci";
0
source

I was getting this error

    <div id="container">
        <h1>A Database Error Occurred</h1>
        <p>Unable to connect to your database server using the provided settings.</p>
        <p>Filename: C:/xampp/htdocs/WORK/Vishal/UI-Demo/system/database/DB_driver.php</p>
        <p>Line Number: 436</p>
    </div>

I solved this error by changing the debug parameter to FALSE in database.php

'db_debug' => (ENVIRONMENT! == 'production'),

TO

'db_debug' => FALSE,

Change it

$db['default'] = array(
'dsn'   => '',
'hostname' => 'XXXX',
'username' => 'XXXX',
'password' => 'XXXX',
'database' => 'XXX',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE

);

For

$db['default'] = array(
'dsn'   => '',
'hostname' => 'XXXX',
'username' => 'XXXX',
'password' => 'XXXX',
'database' => 'XXX',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE

);

0
source

All Articles