前提・実現したいこと
公式チュートリアルcmsを進めていたのですがbakeしようといた際にエラー発生
解決し先に進みたいです
該当ページ
発生している問題・エラーメッセージ
はじめのエラー (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
該当のソースコード
php
1config/app.php 2'Datasources' => [ 3 4 'default' => [ 5 'className' => 'Cake\Database\Connection', 6 'driver' => 'Cake\Database\Driver\Mysql', 7 'persistent' => false, 8 'encoding' => 'utf8mb4', 9 'timezone' => 'UTC', 10 'cacheMetadata' => true, 11 12 13 'quoteIdentifiers' => false, 14 15 16 'unix_socket' => '/opt/lampp/var/mysql/mysql.sock', 17 ],
php
1 2config/app_local.php 3'Datasources' => [ 4 'default' => [ 5 'host' => 'localhost', 6 /* 7 * CakePHP will use the default DB port based on the driver selected 8 * MySQL on MAMP uses port 8889, MAMP users will want to uncomment 9 * the following line and set the port accordingly 10 */ 11 //'port' => 'non_standard_port_number', 12 13 'username' => 'root', 14 'password' => '', 15 16 'database' => 'cake_cms', 17 /* 18 * If not using the default 'public' schema with the PostgreSQL driver 19 * set it here. 20 */ 21 //'schema' => 'myapp', 22 23 /* 24 * You can use a DSN string to set the entire configuration 25 */ 26 'url' => env('DATABASE_URL', null), 27 'unix_socket' => '/opt/lampp/var/mysql/mysql.sock', 28 ],
試したこと
CakePHP3.8でBakeできない場合(DB接続エラー)
こちらが私のケースに当てはまっている気がしましたがMAMPなので下を試しました。
結果がソースコードとエラーメッセージになります
XAMPP環境 海外質問サイト
補足情報(FW/ツールのバージョンなど)
cakephp4, xampp, phpmyadmin
回答1件
あなたの回答
tips
プレビュー