ошибка соединения с базой данных в CodeIgniter

Я пытался запустить CodeIgniter в моей локальной машине, но я получил эту ошибку

кто-нибудь знает в чем проблема? Я использую MAMP на Mac

ErrorException [Fatal Error]: невозможно подключиться к серверу базы данных с использованием предоставленных настроек. / Имя файла: core / Loader.php / Номер строки: 346
APPPATH / controllers / home.php [9]

protected $os_platforms = NULL;

function __construct()
{
parent::__construct();
$this->load->model(strtolower(__CLASS__).'_model', 'model');
$this->load->config('brandmgr', TRUE);

$this->lang->load(strtolower(__CLASS__));
$this->_auto_rootCrumb();
FCPATH/system/database/DB_driver.php [ 1197 ] » MY_Exceptions->show_error(arguments)
FCPATH/system/database/DB_driver.php [ 124 ] » CI_DB_driver->display_error(arguments)
FCPATH/system/database/DB.php [ 148 ] » CI_DB_driver->initialize()
FCPATH/system/core/Loader.php [ 346 ] » DB(arguments)
FCPATH/system/core/Loader.php [ 1171 ] » CI_Loader->database()
FCPATH/system/core/Loader.php [ 152 ] » CI_Loader->_ci_autoloader()
FCPATH/system/core/Controller.php [ 51 ] » CI_Loader->initialize()
APPPATH/core/MY_Controller.php [ 25 ] » CI_Controller->__construct()
APPPATH/controllers/home.php [ 9 ] » MY_Controller->__construct()
FCPATH/system/core/CodeIgniter.php [ 308 ] » Home->__construct()
FCPATH/index.php [ 214 ] » require_once(arguments)

Заранее спасибо!

Вот база данных.php

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$active_group = ENVIRONMENT;
$active_record = TRUE;

$db['development']['hostname'] = 'localhost';
$db['development']['username'] = 'fake';
$db['development']['password'] = 'fake';
$db['development']['database'] = 'bmgr';
$db['development']['dbdriver'] = 'mysqli';
$db['development']['dbprefix'] = '';
$db['development']['pconnect'] = TRUE;
$db['development']['db_debug'] = TRUE;
$db['development']['cache_on'] = FALSE;
$db['development']['cachedir'] = '';
$db['development']['char_set'] = 'utf8';
$db['development']['dbcollat'] = 'utf8_general_ci';
$db['development']['swap_pre'] = '';
$db['development']['autoinit'] = TRUE;
$db['development']['stricton'] = FALSE;

$db['staging']['hostname'] = 'localhost';
$db['staging']['username'] = 'fake';
$db['staging']['password'] = 'fake';
$db['staging']['database'] = 'bmgr1';
$db['staging']['dbdriver'] = 'mysqli';
$db['staging']['dbprefix'] = '';
$db['staging']['pconnect'] = TRUE;
$db['staging']['db_debug'] = TRUE;
$db['staging']['cache_on'] = FALSE;
$db['staging']['cachedir'] = '';
$db['staging']['char_set'] = 'utf8';
$db['staging']['dbcollat'] = 'utf8_general_ci';
$db['staging']['swap_pre'] = '';
$db['staging']['autoinit'] = TRUE;
$db['staging']['stricton'] = FALSE;

добавил среду

define('ENVIRONMENT', 'development');

*---------------------------------------------------------------
* ERROR REPORTING
*---------------------------------------------------------------if (defined('ENVIRONMENT'))
{
switch (ENVIRONMENT)
{
case 'development':
case 'staging':
error_reporting(E_ALL);
ini_set('display_errors', 1);
break;
case 'testing':
case 'production':
error_reporting(0);
ini_set('display_errors', 0);
break;

default:
exit('The application environment is not set correctly.');
}
}

0

Решение

Вам необходимо установить базу данных по умолчанию. например

$active_group = 'development';

или же

$active_group = 'staging';
0

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]