I'm trying to use the PDO MySQL driver in my CodeIgniter application. This is my database config:
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = 'testdatabase';
$db['default']['dbdriver'] = 'pdo';
$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;
However, I'm getting this error when I load a controller:
Fatal error: Uncaught exception 'PDOException' with message 'invalid data source name' in C:\xampp\htdocs\testsite\system\database\drivers\pdo\pdo_driver.php:114
I've checked the data source using die($this->hostname);
in pdo_driver.php
and it's coming out as:
localhost;dbname=testdatabase
so it is getting the correct database name. The database exists and I do have MySQL running.
What could be going wrong here? Thank you.