英文:
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.
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:3307', // Updated hostname to include port 3307
'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 runs on port 3307. It works fine when I try it in Windows.
How to fix this?
英文:
I just clone my code igniter project in mac. When i run it show like this.
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 ?
答案1
得分: 0
可以尝试使用 localhost:3306 或 127.0.0.1:3306 吗?
此外,值得运行一个通过 PHP 代码进行的虚拟 MySQL 连接(在 CI 之外),以确保连接是否有效,或者问题是否出现在 CI 内。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论