Code Igniter数据库配置文件中没有数据库连接

huangapple go评论71阅读模式
英文:

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.

Code Igniter数据库配置文件中没有数据库连接

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.
Code Igniter数据库配置文件中没有数据库连接

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

&lt;?php
defined(&#39;BASEPATH&#39;) OR exit(&#39;No direct script access allowed&#39;);

$active_group = &#39;default&#39;;
$query_builder = TRUE;

$db[&#39;default&#39;] = array(
	&#39;dsn&#39;	=&gt; &#39;&#39;,
	&#39;hostname&#39; =&gt; &#39;localhost&#39;,
	&#39;username&#39; =&gt; &#39;root&#39;,
	&#39;password&#39; =&gt; &#39;&#39;,
	&#39;database&#39; =&gt; &#39;zyacbt&#39;,
	&#39;dbdriver&#39; =&gt; &#39;mysqli&#39;,
	&#39;dbprefix&#39; =&gt; &#39;&#39;,
	&#39;pconnect&#39; =&gt; TRUE,
	&#39;db_debug&#39; =&gt; TRUE,
	&#39;cache_on&#39; =&gt; FALSE,
	&#39;cachedir&#39; =&gt; &#39;&#39;,
	&#39;char_set&#39; =&gt; &#39;utf8&#39;,
	&#39;dbcollat&#39; =&gt; &#39;utf8_general_ci&#39;,
	&#39;swap_pre&#39; =&gt; &#39;&#39;,
	&#39;encrypt&#39; =&gt; FALSE,
	&#39;compress&#39; =&gt; FALSE,
	&#39;stricton&#39; =&gt; FALSE,
	&#39;failover&#39; =&gt; array(),
	&#39;save_queries&#39; =&gt; 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.

huangapple
  • 本文由 发表于 2023年5月25日 12:09:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76328875.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定