In Rails, Couldn't create database for {“adapter”=>“postgresql”,

前端 未结 9 2100
醉话见心
醉话见心 2020-12-14 03:34

I\'m trying to run rake db:create or rake db:setup but I get the following error. It\'s strange because rake db:create it\'s working f

相关标签:
9条回答
  • 2020-12-14 04:15

    Also check you don't have an open connection such as a client or an application connected to the instance. If that happen you will see this in the error

    Couldn't create database for {"adapter"=>"xxxx", "database"=>"xxxx", "host"=>"localhost", "username"=>"postgres", "password"=>"xxxxx", "pool"=>5, "timeout"=>5000}
    rake aborted!
    ActiveRecord::StatementInvalid: PG::ObjectInUse: ERROR:  source database "template1" is being accessed by other users
    DETAIL:  There is 1 other session using the database.
    
    0 讨论(0)
  • 2020-12-14 04:15

    I was able to solve this by making sure that the name of my database in the database.yml file was in the following format: appname_development, appname_test, and appname_production. Here is my database.yml file as an example:

        development:
          adapter: postgresql
          database: parallax_development
          username:
          password:
    
        test:
          adapter: postgresql
          database: parallax_test
          username:
          password:
    
        production:
          adapter: postgresql
          database: parallax_production
          username:
          password:
    
    0 讨论(0)
  • 2020-12-14 04:20

    In my case this was all I needed: https://dba.stackexchange.com/a/75221

    pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
    
    0 讨论(0)
提交回复
热议问题