Using the latest CakePHP 2.0 RC3, I am trying to connect to a MySQL database. To do this, I changed the database.php file present in the app / config directory.
The file contains the following data required to connect to the database.
class DATABASE_CONFIG { public $default = array( 'datasource' => 'Database/Mysql', 'persistent' => false, 'host' => 'localhost', 'login' => 'root', 'password' => '', 'database' => 'db_world', 'prefix' => '' ); }
For root, I tried both to set a password and use an empty password.
- I tried to use the "root" user, and also created another user with the necessary privileges.
- Tried to give 127.0.0.1 instead of 'localhost'
- Checked that the database is connected using a regular php script.
The normal php script for checking the database connection is as follows: -
<?php $connect = mysql_connect("127.0.0.1","root","") or die("Could not connect"); mysql_select_db("db_world") or die("Could not find db"); echo "hello world"; ?>
The above script works, which means that this is not a problem on the part of MySQL.
However, I always get: "Cake cannot connect to the database." Currently, I'm not sure what I am missing here.
Any pointers to fix the problem will be helpful.
mysql cakephp
Jay
source share