0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

database "データベース名" does not existの解決方法

0
Last updated at Posted at 2022-08-23

docker環境にてrails開発している最中にエラーが出る

途中gemを追加後新規にdatabaseを立ち上げlocalhost:3000に接続したところ

FATAL: database "データベース名" does not exist

とエラーが出てしまい接続が出来ない。
エラーを直読みするとdatabase"データベース名"が存在しないと言われている。

なぜ?
今までこんなエラー表示されていなかった為、調べながら解決してみる。
まず定義されているか確認にためdatabase.yml確認するとしっかり定義されている。

続いてコンテナアプリ内に入ります(下記実行)

docker compose exec アプリ名 bash

続いて、databaseが無いなら作成します

rails db:create

Running via Spring preloader in process 56
Created database 'データベース名'

ん・・・できたっぽい?
ってことでもう一度localhost:3000に接続してみとちゃんと接続されました!

調べても案外初歩的なエラーの為、今回載せてみました。
参考になればと思います。

0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?