0
votes

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();
}
1
ah yes, sorry about that. I have updated post. thank you!Don Boots

1 Answers

0
votes

SQLSTATE[42000] [1044] Access denied for user '[user]'@'[host]' to database '[db]'

Means, that cake knows your DB details, but they are not work. "Remove" cake from the chain and try to connect by yourself from index.php.

Then try to connect from console.

Most possible your set wrong DB details or they are not have sufficient permissions on the DB side.