Search code examples
phpmysqlmacoscodeigniterlocalhost

Code Igniter No DB connection in database config file


I just clone my code igniter project in mac. When i run it show like this. enter image description here

I've already add database.php in folder config like this.

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

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

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

My xampp mysql run in port 3307. It's work fine when i try in windows. How to fix this ?


Solution

  • Can you try using localhost:3306 or 127.0.0.1:3306?

    Also worth running a dummy mysql connection through php code (outside CI) to make sure if the connection works at all, or the if the problem is within CI.