我正在尝试将网站上传到服务器。 Code Igniter 是我在这个网站上使用的框架,我是第一次使用 CI。在尝试使用以下数据库设置将网站上传到服务器时:
$db['default'] = array(
'dsn' => 'mysql:host=localhost;dbname=database_name',
'hostname' => 'mysql:host=localhost',
'username' => 'database_user',
'password' => 'database_password',
'database' => 'database_name',
'dbdriver' => 'pdo',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
我一直收到如下错误,我试图在网上搜索以解决我的问题。我发现了一些与我的相似的问题,但我无法弄清楚我应该做什么,因为大多数问题都是针对本地服务器的。请有人帮我解决这个问题,谢谢。
A Database Error Occurred
SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
Filename: controllers/Home.php
Line Number: 9
A PHP Error was encountered
Severity: Warning
Message: PDO::__construct(): The server requested authentication method unknown to the client [mysql_old_password]
Filename: pdo/pdo_driver.php
Line Number: 133
Backtrace:
编辑:
最佳答案
尝试:
$db['default'] = array(
'hostname' => 'localhost',
'username' => 'user',
'password' => 'password',
'database' => 'database_name',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
或
$db['default'] = array(
'dsn' => 'mysql:host=localhost;dbname=codeigniter',
'username' => 'codeigniter',
'password' => 'codeigniter',
'database' => 'codeigniter',
'dbdriver' => 'pdo',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
关于mysql - 代码点火器 : A Database Error Occurred SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38846267/