I recently installed CakePHP on my hostmonster shared server and created a new database and user (with full privileges) and I am getting the following:
Cake is NOT able to connect to the database.
Database connection "Mysql" is missing, or could not be created.
SQLSTATE[42000] [1044] Access denied for user '[user]'@'[host]' to database '[db]'
- bracketed items are not included for security.
I have verified that PDO and PDO mysql are enabled. The credentials have been checked and rechecked many times. Is there some other secret setting that I am missing or is the host limiting control of my database users?
My database.php config:
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'host',
'login' => 'user',
'password' => 'pass',
'database' => 'db',
'prefix' => '',
//'encoding' => 'utf8',
);
public $test = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'host',
'login' => 'user',
'password' => 'pass',
'database' => 'db',
'prefix' => '',
//'encoding' => 'utf8',
);
Furthermore, I have been able to successfully connect to the database via PDO using the same exact credentials via the following code:
$hostname = "host";
$db = "db";
$username = "user";
$password = "pas";
try {
$db = new PDO("mysql:host=$hostname;dbname=$db", $username, $password);
echo "Connected to database";
}
catch(PDOException $e) {
echo $e->getMessage();
}