現在、市販の参考書を参考に、macのターミナルを開き、マイグレーション機能を使ってデータベースを作成するところですが、migrationコマンドでデータベースの準備はできましたが、その後、migrationコマンド「bin/cake migrations migrate」のコマンドを実行すると以下のエラーが出ます。
Exception: There was a problem connecting to the database: SQLSTATE[HY000] [2002] Connection refused In [/Applications/MAMP/htdocs/mycakeapp/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/PdoAdapter.php, line 83] 2020-05-01 12:31:19 Error: [InvalidArgumentException] There was a problem connecting to the database: SQLSTATE[HY000] [2002] Connection refused in /Applications/MAMP/htdocs/mycakeapp/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/PdoAdapter.php on line 83 Stack Trace: - /Applications/MAMP/htdocs/mycakeapp/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/MysqlAdapter.php:130 - /Applications/MAMP/htdocs/mycakeapp/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/PdoAdapter.php:149 - /Applications/MAMP/htdocs/mycakeapp/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/AdapterWrapper.php:504 - /Applications/MAMP/htdocs/mycakeapp/vendor/cakephp/migrations/src/CakeAdapter.php:50 - /Applications/MAMP/htdocs/mycakeapp/vendor/cakephp/migrations/src/Command/Phinx/CommandTrait.php:81 - /Applications/MAMP/htdocs/mycakeapp/vendor/robmorgan/phinx/src/Phinx/Console/Command/Migrate.php:63 - /Applications/MAMP/htdocs/mycakeapp/vendor/cakephp/migrations/src/Command/Phinx/CommandTrait.php:36 - /Applications/MAMP/htdocs/mycakeapp/vendor/cakephp/migrations/src/Command/Phinx/Migrate.php:83 - /Applications/MAMP/htdocs/mycakeapp/vendor/symfony/console/Command/Command.php:255 - /Applications/MAMP/htdocs/mycakeapp/vendor/symfony/console/Application.php:912 - /Applications/MAMP/htdocs/mycakeapp/vendor/symfony/console/Application.php:264 - /Applications/MAMP/htdocs/mycakeapp/vendor/symfony/console/Application.php:140 - /Applications/MAMP/htdocs/mycakeapp/vendor/cakephp/migrations/src/Command/MigrationsCommand.php:126 - /Applications/MAMP/htdocs/mycakeapp/vendor/cakephp/cakephp/src/Console/BaseCommand.php:175 - /Applications/MAMP/htdocs/mycakeapp/vendor/cakephp/migrations/src/Command/MigrationsCommand.php:198 - /Applications/MAMP/htdocs/mycakeapp/vendor/cakephp/cakephp/src/Console/CommandRunner.php:336 - /Applications/MAMP/htdocs/mycakeapp/vendor/cakephp/cakephp/src/Console/CommandRunner.php:171 - /Applications/MAMP/htdocs/mycakeapp/bin/cake.php:12 Caused by: [PDOException] SQLSTATE[HY000] [2002] Connection refused in /Applications/MAMP/htdocs/mycakeapp/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/PdoAdapter.php on line 80 Stack Trace: - /Applications/MAMP/htdocs/mycakeapp/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/PdoAdapter.php:80 - /Applications/MAMP/htdocs/mycakeapp/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/MysqlAdapter.php:130 - /Applications/MAMP/htdocs/mycakeapp/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/PdoAdapter.php:149 - /Applications/MAMP/htdocs/mycakeapp/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/AdapterWrapper.php:504 - /Applications/MAMP/htdocs/mycakeapp/vendor/cakephp/migrations/src/CakeAdapter.php:50 - /Applications/MAMP/htdocs/mycakeapp/vendor/cakephp/migrations/src/Command/Phinx/CommandTrait.php:81 - /Applications/MAMP/htdocs/mycakeapp/vendor/robmorgan/phinx/src/Phinx/Console/Command/Migrate.php:63 - /Applications/MAMP/htdocs/mycakeapp/vendor/cakephp/migrations/src/Command/Phinx/CommandTrait.php:36 - /Applications/MAMP/htdocs/mycakeapp/vendor/cakephp/migrations/src/Command/Phinx/Migrate.php:83 - /Applications/MAMP/htdocs/mycakeapp/vendor/symfony/console/Command/Command.php:255 - /Applications/MAMP/htdocs/mycakeapp/vendor/symfony/console/Application.php:912 - /Applications/MAMP/htdocs/mycakeapp/vendor/symfony/console/Application.php:264 - /Applications/MAMP/htdocs/mycakeapp/vendor/symfony/console/Application.php:140 - /Applications/MAMP/htdocs/mycakeapp/vendor/cakephp/migrations/src/Command/MigrationsCommand.php:126 - /Applications/MAMP/htdocs/mycakeapp/vendor/cakephp/cakephp/src/Console/BaseCommand.php:175 - /Applications/MAMP/htdocs/mycakeapp/vendor/cakephp/migrations/src/Command/MigrationsCommand.php:198 - /Applications/MAMP/htdocs/mycakeapp/vendor/cakephp/cakephp/src/Console/CommandRunner.php:336 - /Applications/MAMP/htdocs/mycakeapp/vendor/cakephp/cakephp/src/Console/CommandRunner.php:171 - /Applications/MAMP/htdocs/mycakeapp/bin/cake.php:12
teratailをみたところ、https://teratail.com/questions/167666がまさに似たような質問であり、一度はこの質問に則ってapp.local.phpのDatasourcesの配列内のhostを127.0.0.1にしてみることで一度は解決しました。
しかし、その後、ターミナル を閉じてパソコンの電源を切って、翌日同じようにやろうとしたところ、また同じエラーが出ました。
完全に前回と同じ手順かは怪しいですが、前回うまくいった方法をとったのにうまくいかず、困惑しています。
どうか解決方法を教えてください。
お願いします。
cakephp 4.0.6です。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。