나는 이것과 관련된 많은 질문을 보았다. 그러나 지금까지는 다른 사람들을 위해 일한 해결책 중 어느 것도 자신을 위해 일하지 않았다. 실행하는 현재 내 시도Rails db : Postgres로 작성하지 못했을 때 역할이 존재하지 않는다.
는 'DB 레일 : 만들기'| 내가 입력 할 때 \ 뒤, 나는 다시 ethansdevcampportfolio를 얻을, 나에게 내 포스트 그레스 콘솔 내에서 다음
[[email protected] EthansDevcampPortfolio]$ rails db:create --trace EDP_DB_PASSWORD='password1' RAILS_ENV=development
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:create
FATAL: role "EthansDevcampPortfolio" does not exist
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "database"=>"EthansDevcampPortfolio_development", "username"=>"EthansDevcampPortfolio", "password"=>"password1", "host"=>nil}
rails aborted!
ActiveRecord::NoDatabaseError: FATAL: role "EthansDevcampPortfolio" does not exist
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:705:in `rescue in connect'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:701:in `connect'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:220:in `initialize'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:38:in `new'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:38:in `postgresql_connection'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:759:in `new_connection'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:803:in `checkout_new_connection'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:782:in `try_to_checkout_new_connection'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:743:in `acquire_connection'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:500:in `checkout'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in `connection'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:931:in `retrieve_connection'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_handling.rb:116:in `retrieve_connection'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_handling.rb:88:in `connection'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/postgresql_database_tasks.rb:10:in `connection'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/postgresql_database_tasks.rb:19:in `create'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/database_tasks.rb:117:in `create'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/database_tasks.rb:137:in `block in create_current'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/database_tasks.rb:304:in `block in each_current_configuration'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/database_tasks.rb:303:in `each'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/database_tasks.rb:303:in `each_current_configuration'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/database_tasks.rb:136:in `create_current'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/railties/databases.rake:27:in `block (2 levels) in <top (required)>'
/home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/task.rb:250:in `block in execute'
/home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/task.rb:250:in `each'
/home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/task.rb:250:in `execute'
/home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/task.rb:194:in `block in invoke_with_call_chain'
/usr/share/ruby/monitor.rb:214:in `mon_synchronize'
/home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain'
/home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/task.rb:180:in `invoke'
/home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/application.rb:152:in `invoke_task'
/home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/application.rb:108:in `block (2 levels) in top_level'
/home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/application.rb:108:in `each'
/home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/application.rb:108:in `block in top_level'
/home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/application.rb:117:in `run_with_threads'
/home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/application.rb:102:in `top_level'
/usr/local/share/gems/gems/railties-5.1.0/lib/rails/commands/rake/rake_command.rb:21:in `block in perform'
/home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
/usr/local/share/gems/gems/railties-5.1.0/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/usr/local/share/gems/gems/railties-5.1.0/lib/rails/command.rb:46:in `invoke'
/usr/local/share/gems/gems/railties-5.1.0/lib/rails/commands.rb:16:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
PG::ConnectionBad: FATAL: role "EthansDevcampPortfolio" does not exist
/home/ethannicolai/.gem/ruby/gems/pg-0.20.0/lib/pg.rb:56:in `initialize'
/home/ethannicolai/.gem/ruby/gems/pg-0.20.0/lib/pg.rb:56:in `new'
/home/ethannicolai/.gem/ruby/gems/pg-0.20.0/lib/pg.rb:56:in `connect'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:701:in `connect'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:220:in `initialize'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:38:in `new'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:38:in `postgresql_connection'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:759:in `new_connection'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:803:in `checkout_new_connection'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:782:in `try_to_checkout_new_connection'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:743:in `acquire_connection'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:500:in `checkout'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in `connection'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:931:in `retrieve_connection'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_handling.rb:116:in `retrieve_connection'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/connection_handling.rb:88:in `connection'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/postgresql_database_tasks.rb:10:in `connection'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/postgresql_database_tasks.rb:19:in `create'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/database_tasks.rb:117:in `create'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/database_tasks.rb:137:in `block in create_current'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/database_tasks.rb:304:in `block in each_current_configuration'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/database_tasks.rb:303:in `each'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/database_tasks.rb:303:in `each_current_configuration'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/tasks/database_tasks.rb:136:in `create_current'
/usr/local/share/gems/gems/activerecord-5.1.0/lib/active_record/railties/databases.rake:27:in `block (2 levels) in <top (required)>'
/home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/task.rb:250:in `block in execute'
/home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/task.rb:250:in `each'
/home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/task.rb:250:in `execute'
/home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/task.rb:194:in `block in invoke_with_call_chain'
/usr/share/ruby/monitor.rb:214:in `mon_synchronize'
/home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain'
/home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/task.rb:180:in `invoke'
/home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/application.rb:152:in `invoke_task'
/home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/application.rb:108:in `block (2 levels) in top_level'
/home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/application.rb:108:in `each'
/home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/application.rb:108:in `block in top_level'
/home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/application.rb:117:in `run_with_threads'
/home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/application.rb:102:in `top_level'
/usr/local/share/gems/gems/railties-5.1.0/lib/rails/commands/rake/rake_command.rb:21:in `block in perform'
/home/ethannicolai/.gem/ruby/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
/usr/local/share/gems/gems/railties-5.1.0/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/usr/local/share/gems/gems/railties-5.1.0/lib/rails/command.rb:46:in `invoke'
/usr/local/share/gems/gems/railties-5.1.0/lib/rails/commands.rb:16:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => db:create
을 받고 수퍼 유저, 상속 없음, 역할 생성, DB 작성
나는 여러 번 사용자 이름과 암호를 조사했다. 내가 보는 장소의 아이디어에서 실행 해요
# PostgreSQL. Versions 9.1 and up are supported.
#
# Install the pg driver:
# gem install pg
# On OS X with Homebrew:
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
# On OS X with MacPorts:
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
# On Windows:
# gem install pg
# Choose the win32 build.
# Install PostgreSQL and put its /bin directory on your path.
#
# Configure Using Gemfile
# gem 'pg'
#
default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see Rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
development:
<<: *default
database: EthansDevcampPortfolio_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: EthansDevcampPortfolio
# The password associated with the postgres role (username).
password: <%= ENV['EDP_DB_PASSWORD'] %>
# Connect on a TCP socket. Omitted by default since the client uses a
# domain socket that doesn't need configuration. Windows does not have
# domain sockets, so uncomment these lines.
host:
# The TCP port the server listens on. Defaults to 5432.
# If your server runs on a different port number, change accordingly.
#port: 5432
# Schema search path. The server defaults to $user,public
#schema_search_path: myapp,sharedapp,public
# Minimum log levels, in increasing order:
# debug5, debug4, debug3, debug2, debug1,
# log, notice, warning, error, fatal, and panic
# Defaults to warning.
#min_messages: notice
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: EthansDevcampPortfolio_test
# As with config/secrets.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password as a unix environment variable when you boot
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full rundown on how to provide these environment variables in a
# production deployment.
#
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="postgres://myuser:[email protected]/somedatabase"
#
# You can use this database configuration with:
#
production:
url: <%= ENV['DATABASE_URL'] %>
#
production:
<<: *default
database: EthansDevcampPortfolio_production
username: EthansDevcampPortfolio
password: <%= ENV['EDP_DB_PASSWORD'] %>
처럼
local all all trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
host all all 0.0.0.0/0 md5(I even tried this at 'trust')
설정은/database.yml을 보이는처럼
있는 pg_hba.conf 보인다. 우연히 포스트 그레스의 인스턴스를 무의식 중 하나로 설치 한 방법이 있다고 생각했습니다. 나는 이것이 모든 것에 대한 멍청이임을 의미하므로 dnf 목록을 설치하고 거기에 postgres의 인스턴스 하나만 보았습니다.
어디에서 볼지, 시도 할 대상 또는 묻는 사람의 아이디어는 환영받을 것입니다.
'username'을'EthansDevcampPortfolio' 대신'database.yml'에서'ethansdevcampportfolio'로 바꾸어보세요. – Pavan