【问题标题】:Severity: Warning Message: mysqli::real_connect(): (HY000/1049): Unknown database 'asboha'严重性:警告消息:mysqli::real_connect(): (HY000/1049): Unknown database 'asboha'
【发布时间】:2020-07-11 08:04:19
【问题描述】:

当我使用 Codeignter 框架并添加数据库名称时,我收到此错误 我用的是XAMPP服务器,从8000改成了8080

我在 config database.php 中的代码

 $db['default'] = array(
    'dsn'   => '',
    'hostname' => 'localhost:3306',
    'username' => 'root',
    'password' => '',
    'database' => 'asboha',
    'dbdriver' => 'mysqli',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' =>FALSE,
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE

【问题讨论】:

  • 尝试用 localhost:3308 替换 localhost:3306

标签: php codeigniter mysqli


【解决方案1】:

尝试将hostname 和port 分开。例如

$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'localhost',
    'port' => 3306,

【讨论】:

  • iam 这样做但没有相同的错误 严重性:警告消息:mysqli::real_connect(): (HY000/1049): Unknown database 'asboha' 文件名:mysqli/mysqli_driver.php 行号:203回溯:
  • 你的 MySQL 服务器中有这样的数据库吗?
  • 是的,我有一个我能做什么?
  • 您需要调试以查看连接中真正使用了哪些值。检查端口是否正确传递。也许某处有错字或不可见的空间。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-03-12
  • 2018-05-16
  • 2018-06-11
  • 2021-01-19
  • 2015-12-31
  • 1970-01-01
相关资源
最近更新 更多