CodeIgniter 错误 "Unable to connect to your database server using the provided settings."
CodeIgniter error "Unable to connect to your database server using the provided settings."
我刚刚开始处理一个包含大量旧代码的旧 CI 项目。该应用程序在服务器上运行良好,但是当我将它拉到我的本地环境(它也在 github 存储库中)时,我收到 "Unable to connect to your database server using the provided settings." 错误。我还有一些在本地运行良好的其他 CodeIgniter 项目。我也试过使用我试图连接到另一个应用程序的数据库,它连接正常。
我已经尝试了一些其他答案的解决方案,例如将驱动程序更改为 mysqli(它已经设置为 mysqli)并更改 php.ini 中的套接字,但它们似乎对我不起作用.
database.php 文件:
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = 'testdatabase';
$db['default']['dbdriver'] = 'mysqli';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
我是 运行 CodeIgniter v2.2.0,XAMPP 使用 phpmyadmin v4.9.0.1,Apache 2.4.4.1 和 PHP 7.1.32
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'testdatabase',
'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
);
试试这个配置。
我刚刚开始处理一个包含大量旧代码的旧 CI 项目。该应用程序在服务器上运行良好,但是当我将它拉到我的本地环境(它也在 github 存储库中)时,我收到 "Unable to connect to your database server using the provided settings." 错误。我还有一些在本地运行良好的其他 CodeIgniter 项目。我也试过使用我试图连接到另一个应用程序的数据库,它连接正常。
我已经尝试了一些其他答案的解决方案,例如将驱动程序更改为 mysqli(它已经设置为 mysqli)并更改 php.ini 中的套接字,但它们似乎对我不起作用.
database.php 文件:
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = 'testdatabase';
$db['default']['dbdriver'] = 'mysqli';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
我是 运行 CodeIgniter v2.2.0,XAMPP 使用 phpmyadmin v4.9.0.1,Apache 2.4.4.1 和 PHP 7.1.32
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'testdatabase',
'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
);
试试这个配置。