使用CodeIgniter出现错误
A Database Error Occurred
SQLSTATE[HY000] [2002] No such file or directory
Filename: controllers/Template.php
Line Number: 15
这是我在application / database.php中的代码
我尝试使用mysqli,但是失败了。我将Google Cloud从标准环境更改为灵活环境后,就会发生此错误。
答案 0 :(得分:1)
请尝试这个。
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'YOUR USERNAME',
'password' => 'YOUR PASSWORD', if you set password in mysql
'database' => 'YOUDATABASE',
'dbdriver' => 'mysqli',
'dbprefix' => 'sss_',
'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
);