0

I have tried this to make local database connection. But it gives this error:

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());
2
  • do you have any database with the name of ci_test in your phpmyadmin ? Commented Aug 2, 2017 at 17:55
  • Please share error message Commented Aug 2, 2017 at 17:56

3 Answers 3

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);

try this. good luck.

Sign up to request clarification or add additional context in comments.

2 Comments

I have just tried this but it gives the same error.
check your database is correct or not?if it is there check this also in config/autoload.php. check this $autoload['libraries'] = array('database'); you have to add database library.
0

This error relates to the connection group, not the database name. The connection group you have specified there is default, as shown on the first line: $db['default'].

Look for:

$active_group = 'ci_test';

Replace it with:

$active_group = 'default';

There is more information in the codeigniter documentation.

Comments

0

You can try this solution for your problem.

$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
);

I hope this will helps you. Thanks!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.