CMS Tutorial: bin/cake bake model users => "Connection to Mysql could not be established"

@Howan Ingo Polster
Mon, 02 Sep 2024 22:50:02 +0000

Hey James,

I finally made it work.
So here my solution for everyone on OSX and MAMP how to make it work.

for MAMP standard port is 8889 for SQL.

 /*
 * CakePHP will use the default DB port based on the driver selected
 * MySQL on MAMP uses port 8889, MAMP users will want to uncomment
 * the following line and set the port accordingly
   */
 'port' => '8889',

But still i couldn’t makle it work like this so i changed Ports in MAMP to normal conventions.
Don’t know why they use other Ports as a default.

After one more hour trying things i found out when allowing network access to MySQL
in MAMP → Settings → MySQL and then connect in the app_local with 127.0.0.1 instead of localhost then i can also bake in the terminal.

This also reflects what is written here under Point 2. Just saw this totally by luck. Should be IMHO in the basic setup guide.
https://book.cakephp.org/bake/2/en/usage.html#

For everyone with the same problem.
This is my app_local.php now. Port can then be untouched.

 'Datasources' => [
        'default' => [
            'host' => '127.0.0.1',
            /*
             * CakePHP will use the default DB port based on the driver selected
             * MySQL on MAMP uses port 8889, MAMP users will want to uncomment
             * the following line and set the port accordingly
             */