LoginSignup
1
0

More than 1 year has passed since last update.

ActiveRecord::ConnectionNotEstablished【MySQL】

Last updated at Posted at 2021-07-28

環境

Ruby 3.0.2
Rails 6.1.4

事象

以下を実行するとエラーが表示された。
①新規Railsアプリを作成(rails new)
②サーバーを起動(rails s)
③localhost:3000を開く。

ActiveRecord::ConnectionNotEstablished

解決策

config/database.ymlでパスワードを設定

database.yml
default: &default
  adapter: mysql2
  encoding: utf8mb4
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  username: root
  password: "<パスワード>"
  socket: /tmp/mysql.sock

development:
  <<: *default
  database: <アプリ名>_development

この後、ActiveRecord::NoDatabaseErrorが出ましたが、これはこちらにまとめて置きます。

参考資料

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0