FATAL: role “root” does not exist

前端 未结 3 1857
后悔当初
后悔当初 2021-01-22 07:24

I have started to learn using heroku and i was trying to execute bundle exec rake db:create db:migrate command, i have encountered the following errors,

         


        
相关标签:
3条回答
  • 2021-01-22 07:47

    The problem is that you don't have ROLE on your local machine named root. Run this in a terminal:

    psql
    

    Then if you connect with PostgreSQL in your terminal:

    CREATE ROLE root WITH PASSWORD 'root' WITH CREATEDB LOGIN CREATEROLE CREATEUSER SUPERUSER;
    

    or just change in your database.yml file user to user, who exists with valid password.

    P.S.

    Don't run in your terminal:

    heroku run rake db:create
    

    Heroku creates for you database when you first time push your application to Heroku's servers.

    But you can run:

    heroku run rake db:migrate
    
    0 讨论(0)
  • 2021-01-22 07:59

    When you add the Heroku Postgres add-on (or simply push a rails app to Heroku, and a dev one is added for you), a database is created for you.

    Do not fun db:create on Heroku Postgres, it's already created. You can skip to db:migrate, et. al

    0 讨论(0)
  • 2021-01-22 07:59

    If u are studying rails tutorial and you want to run a local server,you should have gem 'sqlite3' in gemfile,but if u want to push it to heroku you must replace gem 'sqlite3' with gem 'pg'.Or when running local server you can have them both,but when you push to heroku detele it because it's not suported.

    0 讨论(0)
提交回复
热议问题