DBに接続できない
開発環境:CakePHP2.5.1
「Cake is NOT able to connect to the database.」というエラーが出る
CakePHP2系ではDBへの接続にPDOを利用する形式に変更になりました。PDOはPHP5.1.0以降であれば標準で利用できますが、利用するにはphp.iniの設定が必要になります。
エラーメッセージの内容は次のようなものになります。
1 2 3 4 |
Your database configuration file is present. Cake is NOT able to connect to the database. Database connection "Mysql" is missing, or could not be created. |
上記はMySQLの場合で、PostgreSQLの場合は下記の内容になります。
1 |
Database connection "Postgres" is missing, or could not be created. |
phpinfo(); でPDOの設定を確認して、設定されていなければインストールしてapacheを再起動すれば解決です。
柴田 篤志
最新記事 by 柴田 篤志 (全て見る)
- WordPressとCakePHPの共存 - 2014年10月22日
- サイトマップの作成方法 - 2014年10月12日
- INSERTしたIDを取得する - 2014年10月4日