简体   繁体   中英

Heroku PostgreSQL user and database creation

Currently I have my Ruby on Rails program running great on my Linux Ubuntu development environment, and now I want to run it live on my website, and get it hosted on Heroku.

The problem is that I don't know how to create a user and a database on Heroku. I have tried the command

heroku run rake db:create

I got the error:

permission denied for database - user does nothave connect privilage

I also tried the command

heroku run su - postgres

and it posted that I need to use the terminal so I do not know how to proceed.

This is my database.yml

default: &default
  adapter:  postgresql
  host:     localhost

development:
  <<: *default
  database: app_development

test:
   <<: *default
   database: app_test

production:
  <<: *default
  database: app_production

How do I set up my database and the proper connections with my Heroku PostgreSQL database?

i also did this

heroku pg:info 

which gave me this

shrouded-reaches-3063 has no heroku-postgresql databases.

also tried this

heroku addons | grep POSTGRES

but nothing was printed

heroku addons:create heroku-postgresql:hobby-dev 
!    `addons:create` is not a heroku command.
!    See `heroku help` for a list of available commands.

also this

heroku pg:wait

and displayed nothing... this really is something T_T really need some major help here, and will be really greatful for any help

Have you provisioned a database? What does heroku addons say? You can create an add-on as documented here with heroku addons:create heroku-postgresql:hobby-dev

!!!NOT IN THE DOCUMENTATION!!!

 heroku addons:create heroku-postgresql:hobby-dev --version=12 --app "APPNAME" --name "APPNAME-database"

--app : Specify the heroku app you want to add the database too. Really good if you have more than one heroku app.

--name : The name you would like to give your database. I like to take my application name and postfix it with "database" as a nice convention. Better than whatever randomly generated name you'll get.

APPNAME : A placeholder for whatever your application name is.

No mention of any of this on heroku.com documentation pages for addons in general or postgres addon. I think I came to this via guessing based on documentation for creating apps. But I don't remember. This was in my notes from 5+ years ago. However, I just tried it, still works as of 2022.05.14 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM