2016-03-20 61 views
0

數據庫錯誤連接到你的數據庫服務器發生笨:無法使用提供

無法使用提供的設置連接到你的數據庫服務器。

文件名:庫/會話/ session.php文件

行號:102

我爲CI新手,去我開始dB到我的網站,我得到這個錯誤,我不知道如何reslove。

你能解決這個錯誤嗎?

的application/config/database.php中

$active_group = 'default'; 
    $query_builder = TRUE; 
    require_once('mainconfig.php'); 
$db['default'] = array(
     'dsn' => '', 
     'hostname' => $config['mysql_host'], 
     'username' => $config['mysql_username'], 
     'password' => $config['mysql_password'], 
     'database' => $config['mysql_database'], 
     'dbdriver' => $config['mysql_driver'], 
     'dbprefix' => '', 
     'pconnect' => FALSE, 
     'db_debug' => TRUE, 
     'cache_on' => FALSE, 
     'cachedir' => '', 
     'char_set' => $config['mysql_charset'], 
     'dbcollat' => $config['mysql_dbcollat'], 
     'swap_pre' => '', 
     'encrypt' => FALSE, 
     'compress' => FALSE, 
     'stricton' => FALSE, 
     'failover' => array(), 
     'save_queries' => TRUE 
); 

的application/config/mainconfig.php

defined('BASEPATH') OR exit('No direct script access allowed'); 
$config['mysql_host'] = 'localhost'; 
$config['mysql_username'] = 'xxxcc'; 
$config['mysql_password'] = 'xxxcc'; 
$config['mysql_database'] = 'xxccv'; 
$config['mysql_driver'] = 'mysqli'; 
$config['mysql_charset'] = 'utf8'; 
$config['mysql_dbcollat'] = 'utf8_general_ci'; 
$config['base_js'] = 'assets/js'; 
$config['base_css'] = 'assets/css'; 
$config['base_plugins'] = 'assets/plugins'; 
$config['base_images'] = 'assets/images'; 
$config['base_fonts'] = 'assets/font-awesome'; 
$config['other_base'] = 'assets/fonts'; 
$config['email_author'] = '[email protected]'; 
$config['limit'] = 7; 
+0

檢查application/config/database.php中的數據庫連接 –

+0

需要更多信息。 – user4419336

回答

0

如果u使用笨3,那麼請使用最新版本的PHP。一旦我得到這些錯誤,但然後我更新我的PHP,然後它成功地在我的項目上設置codeigniter後工作。

並請跟隨你的application/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 
); 
+0

我使用PHP 5.5,我必須更新到5.6? – Oryzxo

+0

讓我們試試!但是你有沒有爲你的項目建立一個數據庫? –

+0

我已經完成爲我的項目設置數據庫。 1 – Oryzxo

0

只要改變,這將肯定

$ DB工作[ '默認'] [ '主機'] =「本地主機「;

$分貝[ '缺省'] [ '主機'] = '127.0.0.1';