我尝试过这样做来建立本地数据库连接。但是它给出了这样的错误:
您已经在config/database.php文件中指定了无效的数据库连接组(ci_test)。
$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());发布于 2017-08-02 17:56:55
此错误与连接组有关,而不是数据库名称。您指定的连接组是default,如第一行:$db['default']所示。
寻找:
$active_group = 'ci_test';代之以:
$active_group = 'default';代码点火器文档中有更多的信息。
发布于 2017-08-02 18:06:26
$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);尝尝这个。祝好运。
发布于 2017-08-02 17:58:24
您可以尝试这个解决方案来解决您的问题。
$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
);希望这能帮到你。谢谢!
https://stackoverflow.com/questions/45467791
复制相似问题