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

@Howan Ingo Polster
Mon, 02 Sep 2024 19:00:58 +0000

Hi everyone,

I get exactly the same error here when i try to interact with the database via.

bin/cake bake all users

All information set like in tutorial.

` 'Datasources' => [
        'default' => [
            'host' => 'localhost',
            'port' => '8889',
            'username' => 'root',
            'password' => 'root',
            'database' => 'cake_cms',
            'url' => env('DATABASE_URL', null),
        ],`

2024-09-02 18:30:16 error: [Cake\Database\Exception\MissingConnectionException] Connection to Mysql could not be established: SQLSTATE[HY000] [2002] No such file or directory in /Users/ingopolster/Sites/hausverwaltung/vendor/cakephp/cakephp/src/Database/Driver.php on line 192
Exception Attributes: array (
  'driver' => 'Mysql',
  'reason' => 'SQLSTATE[HY000] [2002] No such file or directory',
)

Full Error message.

2024-09-02 18:48:18 error: [Cake\Database\Exception\MissingConnectionException] Connection to Mysql could not be established: SQLSTATE[HY000] [2002] No such file or directory in /Users/ingopolster/Sites/hausverwaltung/vendor/cakephp/cakephp/src/Database/Driver.php on line 192
Exception Attributes: array (
  'driver' => 'Mysql',
  'reason' => 'SQLSTATE[HY000] [2002] No such file or directory',
)
Stack Trace:
- /Users/ingopolster/Sites/hausverwaltung/vendor/cakephp/cakephp/src/Database/Driver/Mysql.php:151
- /Users/ingopolster/Sites/hausverwaltung/vendor/cakephp/cakephp/src/Database/Schema/SchemaDialect.php:51
- /Users/ingopolster/Sites/hausverwaltung/vendor/cakephp/cakephp/src/Database/Driver/Mysql.php:179
- /Users/ingopolster/Sites/hausverwaltung/vendor/cakephp/cakephp/src/Database/Schema/Collection.php:53
- /Users/ingopolster/Sites/hausverwaltung/vendor/cakephp/cakephp/src/Database/Connection.php:362
- /Users/ingopolster/Sites/hausverwaltung/vendor/cakephp/bake/src/Command/ModelCommand.php:92
- /Users/ingopolster/Sites/hausverwaltung/vendor/cakephp/bake/src/Command/AllCommand.php:115
- /Users/ingopolster/Sites/hausverwaltung/vendor/cakephp/cakephp/src/Console/BaseCommand.php:192
- /Users/ingopolster/Sites/hausverwaltung/vendor/cakephp/cakephp/src/Console/CommandRunner.php:327
- /Users/ingopolster/Sites/hausverwaltung/vendor/cakephp/cakephp/src/Console/CommandRunner.php:168
- /Users/ingopolster/Sites/hausverwaltung/bin/cake.php:10
- [main]:

Caused by: [PDOException] SQLSTATE[HY000] [2002] No such file or directory in /Users/ingopolster/Sites/hausverwaltung/vendor/cakephp/cakephp/src/Database/Driver.php on line 181
Stack Trace:
- /Users/ingopolster/Sites/hausverwaltung/vendor/cakephp/cakephp/src/Database/Driver.php:181
- /Users/ingopolster/Sites/hausverwaltung/vendor/cakephp/cakephp/src/Core/Retry/CommandRetry.php:71
- /Users/ingopolster/Sites/hausverwaltung/vendor/cakephp/cakephp/src/Database/Driver.php:190
- /Users/ingopolster/Sites/hausverwaltung/vendor/cakephp/cakephp/src/Database/Driver/Mysql.php:151
- /Users/ingopolster/Sites/hausverwaltung/vendor/cakephp/cakephp/src/Database/Schema/SchemaDialect.php:51
- /Users/ingopolster/Sites/hausverwaltung/vendor/cakephp/cakephp/src/Database/Driver/Mysql.php:179
- /Users/ingopolster/Sites/hausverwaltung/vendor/cakephp/cakephp/src/Database/Schema/Collection.php:53
- /Users/ingopolster/Sites/hausverwaltung/vendor/cakephp/cakephp/src/Database/Connection.php:362
- /Users/ingopolster/Sites/hausverwaltung/vendor/cakephp/bake/src/Command/ModelCommand.php:92
- /Users/ingopolster/Sites/hausverwaltung/vendor/cakephp/bake/src/Command/AllCommand.php:115
- /Users/ingopolster/Sites/hausverwaltung/vendor/cakephp/cakephp/src/Console/BaseCommand.php:192
- /Users/ingopolster/Sites/hausverwaltung/vendor/cakephp/cakephp/src/Console/CommandRunner.php:327
- /Users/ingopolster/Sites/hausverwaltung/vendor/cakephp/cakephp/src/Console/CommandRunner.php:168
- /Users/ingopolster/Sites/hausverwaltung/bin/cake.php:10
- [main]:

[Cake\Database\Exception\MissingConnectionException] Connection to Mysql could not be established: SQLSTATE[HY000] [2002] No such file or directory in /Users/ingopolster/Sites/hausverwaltung/vendor/cakephp/cakephp/src/Database/Driver.php on line 192

Exception Attributes

array (
  'driver' => 'Mysql',
  'reason' => 'SQLSTATE[HY000] [2002] No such file or directory',
)

Stack Trace:

Cake\Database\Driver->createPdo() - CORE/src/Database/Driver/Mysql.php, line 151
Cake\Database\Driver\Mysql->connect() - CORE/src/Database/Schema/SchemaDialect.php, line 51
Cake\Database\Schema\SchemaDialect->__construct() - CORE/src/Database/Driver/Mysql.php, line 179
Cake\Database\Driver\Mysql->schemaDialect() - CORE/src/Database/Schema/Collection.php, line 53
Cake\Database\Schema\Collection->__construct() - CORE/src/Database/Connection.php, line 362
Cake\Database\Connection->getSchemaCollection() - ROOT/vendor/cakephp/bake/src/Command/ModelCommand.php, line 92
Bake\Command\ModelCommand->execute() - ROOT/vendor/cakephp/bake/src/Command/AllCommand.php, line 115
Bake\Command\AllCommand->execute() - CORE/src/Console/BaseCommand.php, line 192
Cake\Console\BaseCommand->run() - CORE/src/Console/CommandRunner.php, line 327
Cake\Console\CommandRunner->runCommand() - CORE/src/Console/CommandRunner.php, line 168
Cake\Console\CommandRunner->run() - ROOT/bin/cake.php, line 10
[main] - [main], line 0

Caused by [PDOException] SQLSTATE[HY000] [2002] No such file or directory in /Users/ingopolster/Sites/hausverwaltung/vendor/cakephp/cakephp/src/Database/Driver.php on line 181

Stack Trace:

PDO->__construct() - CORE/src/Database/Driver.php, line 181
Cake\Database\Driver->Cake\Database\{closure}() - CORE/src/Core/Retry/CommandRetry.php, line 71
Cake\Core\Retry\CommandRetry->run() - CORE/src/Database/Driver.php, line 190
[main] - [main], line 0

ingopolster@Ingos-MacBook-Pro hausverwaltung %