前提・実現したいこと
プログラミング初心者で、テキストを見ながら勉強しています。
【現在までの流れ】
RubyとRailsをインストール
↓
Ubuntuをインストール
↓
postgreSQL(10.7)をインストールし、
データベースユーザー名をUbuntuのログインユーザーと同じに設定。
↓
Railsアプリ「scaffold_app」を新規作成
↓
データベース作成時にエラー発生
発生している問題・エラーメッセージ
fe_sendauth: no password supplied Couldn't create 'scaffold_app_development' database. Please check your configuration. rails aborted! PG::ConnectionBad: fe_sendauth: no password supplied bin/rails:4:in `require' bin/rails:4:in `<main>' Tasks: TOP => db:create (See full trace by running task with --trace)
該当のソースコード
bin/rails db:create
試したこと
エラーの読み方がよくわからず、ネットで検索しながら探り探りの状態ですが
以下のことを試しました。
config/database.ymlを以下のように書き換える
default: &default adapter: postgresql encoding: utf8 # For details on connection pooling, see Rails configuration guide # http://guides.rubyonrails.org/configuring.html#database-pooling pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> username: user password: pass host: localhost timeout: 5000 development: <<: *default database: scaffold_app_development # The specified database role being used to connect to postgres. # To create additional roles in postgres see `$ createuser --help`. # When left blank, postgres will use the default role. This is # the same name as the operating system user that initialized the database. username: scaffold_app # The password associated with the postgres role (username). password: test: <<: *default database: scaffold_app_test production: <<: *default database: scaffold_app_production
/etc/postgresql/10/main/pg_hba.confの設定をtrustにする。
# "local" is for Unix domain socket connections only local all all trust # IPv4 local connections: host all all 127.0.0.1/32 trust # IPv6 local connections: host all all ::1/128 trust
この後、再度データベースを作成するコマンドを実行したところ、事態を悪化させてしまったようです。。
FATAL: role "scaffold_app" does not exist Couldn't create 'scaffold_app_development' database. Please check your configuration. rails aborted! ActiveRecord::NoDatabaseError: FATAL: role "scaffold_app" does not exist bin/rails:4:in `require' bin/rails:4:in `<main>' Caused by: PG::ConnectionBad: FATAL: role "scaffold_app" does not exist bin/rails:4:in `require' bin/rails:4:in `<main>' Tasks: TOP => db:create (See full trace by running task with --trace)
検討違いの事を試しているかもしれませんが、
何卒ご回答をよろしくお願いいたします。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。