0

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

Yogesh Saroya
  • 1,401
  • 5
  • 23
  • 52
  • possible duplicate of [CakePHP Database connection "Mysql" is missing, or could not be created](http://stackoverflow.com/questions/19280245/cakephp-database-connection-mysql-is-missing-or-could-not-be-created) – AD7six Jun 13 '14 at 07:40

2 Answers2

1

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.

Community
  • 1
  • 1
AD7six
  • 63,116
  • 12
  • 91
  • 123
  • actually i had deleted $abcd and now using $default, but problem still same. – Yogesh Saroya Jun 12 '14 at 10:49
  • i have updated latest screenshot. please check . thanks – Yogesh Saroya Jun 12 '14 at 10:53
  • Which now makes the question a duplicate of all the other cakephp-mysql-is-missing questions. As an aside - please don't use screenshots to show text - _just put the text_. – AD7six Jun 12 '14 at 12:17
  • Probably mysql's socket not being where php thinks it is. If it works for web requests - that's almost certainly the case - e.g. compare [pdo_mysql.default_socket](http://es1.php.net/manual/en/ref.pdo-mysql.php#ini.pdo-mysql.default-socket) for web and cli requests. Alternatively `what is the solution?` - reading the duplicate questions and answers. – AD7six Jun 13 '14 at 07:39
0

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',
);
Kiluminati
  • 73
  • 10