プログラミング初心者です。
ローカル環境にてrails serverを実行し、サーバーを立ち上げようとしています。
ブラウザのアドレスバーにhttp://localhost:3000を貼り付けましたが、以下のようなエラーメッセージが表示されてしまいます。
エラーメッセージ
ActiveRecord::ConnectionNotEstablished Access denied for user 'root'@'localhost' (using password: NO) Extracted source (around line #45): 43 raise ActiveRecord::NoDatabaseError 44 else 45 raise ActiveRecord::ConnectionNotEstablished, error.message 46 end 47 end 48 end Rails.root: /Users/ユーザー名/project/my-portfolio Application Trace | Framework Trace | Full Trace activerecord (6.1.3) lib/active_record/connection_adapters/mysql2_adapter.rb:45:in `rescue in new_client' activerecord (6.1.3) lib/active_record/connection_adapters/mysql2_adapter.rb:39:in `new_client' activerecord (6.1.3) lib/active_record/connection_adapters/mysql2_adapter.rb:23:in `mysql2_connection' activerecord (6.1.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `public_send' activerecord (6.1.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `new_connection' activerecord (6.1.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:926:in `checkout_new_connection' activerecord (6.1.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:905:in `try_to_checkout_new_connection' activerecord (6.1.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:866:in `acquire_connection' activerecord (6.1.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:588:in `checkout' activerecord (6.1.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:428:in `connection' activerecord (6.1.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:1128:in `retrieve_connection' activerecord (6.1.3) lib/active_record/connection_handling.rb:327:in `retrieve_connection' activerecord (6.1.3) lib/active_record/connection_handling.rb:283:in `connection' activerecord (6.1.3) lib/active_record/migration.rb:611:in `connection' activerecord (6.1.3) lib/active_record/migration.rb:606:in `build_watcher' activerecord (6.1.3) lib/active_record/migration.rb:588:in `block in call' activerecord (6.1.3) lib/active_record/migration.rb:587:in `synchronize' activerecord (6.1.3) lib/active_record/migration.rb:587:in `call' actionpack (6.1.3) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call' activesupport (6.1.3) lib/active_support/callbacks.rb:98:in `run_callbacks' actionpack (6.1.3) lib/action_dispatch/middleware/callbacks.rb:26:in `call' actionpack (6.1.3) lib/action_dispatch/middleware/executor.rb:14:in `call' actionpack (6.1.3) lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call' actionpack (6.1.3) lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call' web-console (4.1.0) lib/web_console/middleware.rb:132:in `call_app' web-console (4.1.0) lib/web_console/middleware.rb:28:in `block in call' web-console (4.1.0) lib/web_console/middleware.rb:17:in `catch' web-console (4.1.0) lib/web_console/middleware.rb:17:in `call' actionpack (6.1.3) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call' railties (6.1.3) lib/rails/rack/logger.rb:37:in `call_app' railties (6.1.3) lib/rails/rack/logger.rb:26:in `block in call' activesupport (6.1.3) lib/active_support/tagged_logging.rb:99:in `block in tagged' activesupport (6.1.3) lib/active_support/tagged_logging.rb:37:in `tagged' activesupport (6.1.3) lib/active_support/tagged_logging.rb:99:in `tagged' railties (6.1.3) lib/rails/rack/logger.rb:26:in `call' sprockets-rails (3.2.2) lib/sprockets/rails/quiet_assets.rb:13:in `call' actionpack (6.1.3) lib/action_dispatch/middleware/remote_ip.rb:81:in `call' actionpack (6.1.3) lib/action_dispatch/middleware/request_id.rb:26:in `call' rack (2.2.3) lib/rack/method_override.rb:24:in `call' rack (2.2.3) lib/rack/runtime.rb:22:in `call' activesupport (6.1.3) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call' actionpack (6.1.3) lib/action_dispatch/middleware/executor.rb:14:in `call' actionpack (6.1.3) lib/action_dispatch/middleware/static.rb:24:in `call' rack (2.2.3) lib/rack/sendfile.rb:110:in `call' actionpack (6.1.3) lib/action_dispatch/middleware/host_authorization.rb:98:in `call' rack-mini-profiler (2.3.1) lib/mini_profiler/profiler.rb:373:in `call' webpacker (5.2.1) lib/webpacker/dev_server_proxy.rb:25:in `perform_request' rack-proxy (0.6.5) lib/rack/proxy.rb:57:in `call' railties (6.1.3) lib/rails/engine.rb:539:in `call' puma (5.2.2) lib/puma/configuration.rb:248:in `call' puma (5.2.2) lib/puma/request.rb:76:in `block in handle_request' puma (5.2.2) lib/puma/thread_pool.rb:337:in `with_force_shutdown' puma (5.2.2) lib/puma/request.rb:75:in `handle_request' puma (5.2.2) lib/puma/server.rb:431:in `process_client' puma (5.2.2) lib/puma/thread_pool.rb:145:in `block in spawn_thread' Exception Causes Mysql2::Error::ConnectionError: Access denied for user 'root'@'localhost' (using password: NO)
調べたところ、
ActiveRecord::ConnectionNotEstablishedは
データベースへの接続を確立できなかった場合に発生するエラーで、
Access denied for user 'root'@'localhost' (using password: NO)は
パスワードがないから開かないという意味であることまでは分かったのですが、
具体的な解決策が調べてもよくわかりませんでした。
どのようにすればエラーが解消できますでしょうか。
ご教示いただけますと幸いです。
補足情報(FW/ツールのバージョンなど)
macOs Catalina 10.15.7
ruby 2.7.0
Rails 6.1.1
Bundler 1.17.2
教材「Ruby on Rails チュートリアル」に沿って勉強しています。(https://railstutorial.jp/chapters/beginning?version=6.0)
回答1件
あなたの回答
tips
プレビュー