2017-08-02 24 views
0

これを試して、ローカルデータベース接続を試みました。しかし、それは、このエラーを与える:CodeIgniterローカルデータベース接続の問題

You have specified an invalid database connection group (ci_test) in your config/database.php file.

$db['default'] = array(
    'dsn' => '', 
    'hostname' => 'localhost', // pass this 
    'username' => 'root', // pass this 
    'password' => '', // pass this 
    'database' => 'ci_test', // pass this 
    'dbdriver' => 'mysqli', 
    'dbprefix' => '', 
    'pconnect' => TRUE, 
    'db_debug' => TRUE, 
    'cache_on' => FALSE, 
    'cachedir' => '', 
    'char_set' => 'utf8', 
    'dbcollat' => 'utf8_general_ci', 
    'swap_pre' => '', 
    'encrypt' => FALSE, 
    'compress' => FALSE, 
    'stricton' => FALSE, 
    'failover' => array()); 
+0

phpmyadminにci_testという名前のデータベースがありますか? – Jok3r

+0

エラーメッセージを共有してください –

答えて

0

このエラーは、接続グループではなく、データベース名に関連します。最初に指定した接続グループはdefaultです($db['default'])。

$active_group = 'ci_test'; 

でそれを置き換えます:

$active_group = 'default'; 

より多くの情報がcodeigniter documentationであるため

ルック。

0

あなたの問題に対してこの解決策を試すことができます。

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

$db['default'] = array(
    'dsn' => '', 
    'hostname' => 'localhost', 
    'username' => 'root', 
    'password' => 'root', 
    'database' => 'ci_test', 
    '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
$active_group = 'default'; 
$query_builder = TRUE; 


$db['default'] = array(

'dsn' => '', 
'hostname' => 'localhost', //this will be same 
'username' => 'root', //replace with your username 
'password' => '',  //replace with your password 
'database' => 'test', //replace with your database name which you want to use 
'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

私はこれを試しましたが、同じエラーが発生します。 – Aman

+0

ここにエラーメッセージ.postを表示してください。 – Jok3r

+0

あなたのデータベースが正しいかどうかチェックしてください。もしあれば、これもconfig/autoload.phpでチェックしてください。これをチェックする$ autoload ['libraries'] = array( 'database');データベースライブラリを追加する必要があります。 – Jok3r