Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have an issue here with baking.
I've read the previous answers to similar questions, but the solutions seem to not apply here.

I can't bake because the error I receive is: Database connection “Mysql” is missing, or could not be created

If I run which php the PHP it's reading is the correct path within MAMP.

If I check the PDO modules:

php -i | grep "PDO"
PDO
PDO support => enabled
PDO drivers => sqlite, pgsql, mysql
PDO Driver for MySQL => enabled
PDO Driver for PostgreSQL => enabled
PDO Driver for SQLite 3.x => enabled

My application (or what I've completed on it so far) has no trouble connecting to the database.

All answers around the web point to PDO not being enabled, or the incorrect path for PHP, but neither of those apply in my case.

like image 592
Dan Hanly Avatar asked Jul 30 '13 16:07

Dan Hanly


2 Answers

Another solution (Mac and MAMP) is to update your database connection HOST. I had specified localhost and received this error message. When I updated the host to 127.0.0.1 cake was able to make the connection.

The symlink method described by cfkane should also address the issue.

like image 148
Todd Avatar answered Sep 22 '22 17:09

Todd


Maybe a wrong username / password or misspelled database name. I once had a database (name) beginning with a space.

You may want to check the database connection using plain PHP, see.

like image 34
tersmitten Avatar answered Sep 26 '22 17:09

tersmitten