将mysql数据库与php Codeigniter连接时出错

时间:2015-09-02 19:18:31

标签: php database codeigniter

我正在使用Codeigniter,我无法连接我的数据库,给我一个错误: Error connecting database

我只是在autoload.php中添加库:

`$autoload['libraries'] = array('database');`

这是我在database.php中的设置

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

$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'localhost',
    'username' => 'root',
    'password' => 'root',
    'database' => 'heroes',
    '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 个答案:

答案 0 :(得分:1)

我刚刚通过127.0.0.1:3306

更改了localhost