当我尝试运行bundle exec rake db:setup
时,它给了我这个错误
当我将适配器更改为我的用户名时,我得到了同样的错误
PG::InsufficientPrivilege: ERROR: permission denied to create database
: CREATE DATABASE "freelance_camp_documents_development" ENCODING = 'unicode'
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "database"=>"freelance_camp_documents_development"}
rake aborted!
ActiveRecord::StatementInvalid: PG::InsufficientPrivilege: ERROR: permission denied to create database
: CREATE DATABASE "freelance_camp_documents_development" ENCODING = 'unicode'
/usr/local/share/gems/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `async_exec'
/usr/local/share/gems/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `block in execute'
/usr/local/share/gems/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:566:in `block in log'
/usr/local/share/gems/gems/activesupport-
我不能把整个错误放在这里
这是database.yml
代码
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: freelance_camp_documents_development
test:
<<: *default
database: freelance_camp_documents_test
production:
<<: *default
database: freelance_camp_documents_production
username: freelance_camp_documents
password: <%= ENV['FREELANCE_CAMP_DOCUMENTS_DATABASE_PASSWORD'] %>
答案 0 :(得分:0)
PG :: InsufficientPrivilege:错误:拒绝创建数据库的权限
这里的问题是你没有足够的权限在Postgres上用户freelance_camp_documents
。
我建议您从postgres更改用户freelance_camp_documents
的权限,或者只需将用户名更改为postgres
production:
<<: *default
database: freelance_camp_documents_production
username: postgres
password: <%= ENV['FREELANCE_CAMP_DOCUMENTS_DATABASE_PASSWORD'] %>
postgres
用户默认拥有权限,因此您无需更改任何内容