Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cake php Datasource class MySQL could not be found

I have ubuntu 10.04 on server. I am trying to set up the cake php project but it gives me following error

   Cake is NOT able to connect to the database.

   Datasource class MySQL could not be found.

I have searched lot on the web regarding it. my config file looks like this

  class DATABASE_CONFIG {

public $default = array(
    'datasource' => 'Database/MySQL',
    'persistent' => false,
    'host' => 'localhost',
    'login' => 'root',
    'password' => 'mypassword',
    'database' => 'dbname',
    'prefix' => '',
    //'encoding' => 'utf8',
);
 }

I checked that server has all the things set up to connect as PDO I have run following script and it works fine.

    $conn = new PDO('mysql:host=localhost;dbname=dbname', $username, $password);

Then further I have changed in Mysql.php file of cake php which is in the "lib\Cake\Model\Datasource\Database"

I tried to give static connection in Mysql.php but this also doesn't work. I did exit in the Mysql.php and seems like control of page is not getting here.

    $this->_connection = new PDO('mysql:host=localhost;dbname=dbname', $username, $password);
$this->connected = true;

Please do let me know if I am missing anything.

Thanks in Advance.

like image 886
Satish Avatar asked Jan 16 '23 03:01

Satish


1 Answers

Casing matters, it should be:

'datasource' => 'Database/Mysql'

And not:

'datasource' => 'Database/MySQL'
like image 56
ADmad Avatar answered Jan 17 '23 17:01

ADmad