php - 无法连接到数据库。主连接 [MySQLi]:用户 @ 的访问被拒绝(使用密码:是)
问题描述
CodeIgniter\Database\Exceptions\DatabaseException #8 无法连接到数据库。主连接 [MySQLi]:用户 'xxxx'@'localhost' 的访问被拒绝(使用密码:YES)
我正在尝试访问我的程序,但我无法连接数据库。我怎么做?因为我还是初学者
public $default = [
'DSN' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'starter',
'DBDriver' => 'MySQLi',
'DBPrefix' => '',
'pConnect' => false,
'DBDebug' => (ENVIRONMENT !== 'production'),
'cacheOn' => false,
'cacheDir' => '',
'charset' => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
// 'failover' => array(),
// 'save_queries'=> TRUE,
'port' => 3306,
];
public $tests = [
'DSN' => '',
'hostname' => '127.0.0.1',
'username' => 'root',
'password' => '',
'database' => ':memory:',
'DBDriver' => 'SQLite3',
'DBPrefix' => 'db_', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS
'pConnect' => false,
'DBDebug' => (ENVIRONMENT !== 'production ),
'cacheOn' => false,
'cacheDir' => '',
'charset' => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port' => 3306,
];
解决方案
推荐阅读
- python - 如何为 ECS 任务定义创建日志记录?
- spring - 为什么轴突框架不能插入到自己的表中?
- javascript - 无法读取未定义的属性“id”
- node.js - 用于响应和表达受保护路由的 JSON webtoken 登录授权
- c# - 如何在 C#/.net 中将 XML 数据链接在一起
- python-3.x - 如何识别和计算矩形中的圆?
- github - 在同一个网站(Jekyll GitHub)上创建两个博客而不改变布局/格式
- excel - 如何使用 Excel VBA 单击 Web 复选框?
- facebook - 如何在没有访问令牌的组中发布帖子
- javascript - 无法将数据存储在离子 ios 的本地存储中