我最近安裝的CakePHP我HostMonster的共享服務器,並創建一個新的數據庫和用戶(擁有完全權限)和我得到以下幾點:CakePHP數據庫錯誤。拒絕訪問
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]'
- 括號內的項目不包括在內的安全性。
我已驗證PDO和PDO mysql已啓用。憑證已經過多次檢查和重新檢查。是否有一些其他的祕密設置,我缺少或主機限制我的數據庫用戶的控制?
我database.php中配置:
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',
);
而且,我已經能夠成功地通過使用PDO完全相同的憑證通過下面的代碼連接到數據庫:
$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();
}
你配置了你的db連接嗎? http://book.cakephp.org/1.3/en/The-Manual/Developing-with-CakePHP/Configuration.html – 2013-03-28 01:19:36
啊是的,對不起。我更新了帖子。謝謝! – 2013-03-28 01:26:53