Yogesh Saroya
Yogesh Saroya

Reputation: 1495

CakePHP Bake Error: Database connection “Mysql” is missing, or could not be created

i just download the cakephp 2.5.1 extract and create a database.

now i am try to using cake bake but terminal showing that error (i am using ubuntu)

Error: Database connection “Mysql” is missing, or could not be created

also no issue with database connection.just tested with pages/index function. its working fine.

should i used empty table ? currently i am using current project database.

database.php

class DATABASE_CONFIG {

public $default = array(
    'datasource' => 'Database/Mysql',
    'persistent' => false,
    'host' => 'localhost',
    'login' => 'root',
    'password' => '',
    'database' => 'abcd',
    'prefix' => 'lab_',
    'encoding' => 'utf8',
);
public $test = array(
    'datasource' => 'Database/Mysql',
    'persistent' => false,
    'host' => 'localhost',
    'login' => 'user',
    'password' => 'password',
    'database' => 'test_database_name',
    'encoding' => 'utf8',
);

}

enter image description here

Sql connect working fine ( find query result ) > enter image description here

Thanks

update > cake bake screenshot - update

Upvotes: 0

Views: 5265

Answers (2)

Kiluminati
Kiluminati

Reputation: 73

Try locating 'mysql.sock' and add the path (eg: /tmp/mysql.sock) of this file to the database config entry 'unix_socket'. so your database config looks like this:

public $default = array(
    'datasource' => 'Database/Mysql',
    'persistent' => false,
    'host' => 'localhost',
    'login' => 'root',
    'password' => '',
    'database' => 'abcd',
    'prefix' => 'lab_',
    'encoding' => 'utf8',
    'unix_socket' => '/tmp/mysql.sock',
);

Upvotes: 0

AD7six
AD7six

Reputation: 66170

Connection, not database

The question is asking which database connection to use - not which database to use i.e.

Which of these to use?

public $default = array();
       ^ This one?
public $test = array();
       ^ Or this one?

Answering abcd will cause bake to look for and use public $abcd in the database config class - which evidently is misconfigured.

Upvotes: 1

Related Questions