Home>

I was advancing the official tutorial cms, but an error occurred when trying to bake
I want to solve it and move on
Corresponding page

First error
(base) perrymb: cms a0000 $pwd
/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms
(base) perrymb: cms a0000 $bin/cake bake model users
One moment while associations are detected.
Exception: Connection to Mysql could not be established: SQLSTATE [HY000] [2002] No such file or directory
In [/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/cakephp/src/Database/Driver.php, line 140]
2020-11-23 05:07:49 Error: [Cake \ Database \ Exception \ MissingConnectionException] Connection to Mysql could not be established: SQLSTATE [HY000] [2002] No such file or directory in /Users/a0000/.bitnami/ stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/cakephp/src/Database/Driver.php on line 140
Exception Attributes: array (
  'driver' =>'Mysql',
  'reason' =>'SQLSTATE [HY000] [2002] No such file or directory',
)
Stack Trace:
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/cakephp/src/Database/Driver/Mysql.php:178
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/cakephp/src/Database/Schema/SchemaDialect.php:47
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/cakephp/src/Database/Driver/Mysql.php:230
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/cakephp/src/Database/Schema/Collection.php:53
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/cakephp/src/Database/Connection.php:399
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/bake/src/Utility/TableScanner.php:65
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/bake/src/Command/ModelCommand.php:1060
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/bake/src/Command/ModelCommand.php:191
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/bake/src/Command/ModelCommand.php:122
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/bake/src/Command/ModelCommand.php:98
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/bake/src/Command/ModelCommand.php:81
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/cakephp/src/Console/BaseCommand.php:179
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/cakephp/src/Console/CommandRunner.php:335
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/cakephp/src/Console/CommandRunner.php:171
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/bin/cake.php:12
Caused by: [PDOException] SQLSTATE [HY000] [2002] No such file or directory in /Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/cakephp/src/Database /Driver.php on line 132
Stack Trace:-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/cakephp/src/Database/Driver.php:132
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/cakephp/src/Core/Retry/CommandRetry.php:70
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/cakephp/src/Database/Driver.php:138
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/cakephp/src/Database/Driver/Mysql.php:178
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/cakephp/src/Database/Schema/SchemaDialect.php:47
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/cakephp/src/Database/Driver/Mysql.php:230
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/cakephp/src/Database/Schema/Collection.php:53
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/cakephp/src/Database/Connection.php:399
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/bake/src/Utility/TableScanner.php:65
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/bake/src/Command/ModelCommand.php:1060
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/bake/src/Command/ModelCommand.php:191
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/bake/src/Command/ModelCommand.php:122
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/bake/src/Command/ModelCommand.php:98
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/bake/src/Command/ModelCommand.php:81
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/cakephp/src/Console/BaseCommand.php:179
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/cakephp/src/Console/CommandRunner.php:335
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/vendor/cakephp/cakephp/src/Console/CommandRunner.php:171
-/Users/a0000/.bitnami/stackman/machines/xampp/volumes/root/htdocs/cms/bin/cake.php:12
Corresponding source code
config/app.php
'Datasources' =>[
        'default' =>[
            'className' =>'Cake \ Database \ Connection',
            'driver' =>'Cake \ Database \ Driver \ Mysql',
            'persistent' =>false,
            'encoding' =>'utf8mb4',
            'timezone' =>'UTC',
            'cacheMetadata' =>true,

            'quoteIdentifiers' =>false,

            'unix_socket' =>'/opt/lampp/var/mysql/mysql.sock',
        ],,

config/app_local.php
'Datasources' =>[
        'default' =>[
            'host' =>'localhost',
           /*
             * 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' =>'non_standard_port_number',
            'username' =>'root',
            'password' =>'',
            'database' =>'cake_cms',
           /*
             * If not using the default'public' schema with the PostgreSQL driver
             * set it here.
             * /
            //'schema'=>'myapp',
           /*
             * You can use a DSN string to set the entire configuration
             * /
            'url' =>env ('DATABASE_URL', null),
            'unix_socket' =>'/opt/lampp/var/mysql/mysql.sock',
        ],,

What I tried

If i cannot Bake with CakePHP3.8 (DB connection error)
I felt that this was the case for me, but since it's MAMP, I tried the following.
The result is the source code and the error message
XAMPP environment overseas question site

Supplementary information (FW/tool version, etc.)

cakephp4, xampp, phpmyadmin