Answer the question
In order to leave comments, you need to log in
How to set up postgresql in Ruby on Rails?
Every time I create a new project, I have to sudo -u postgres psql and create new databases.
How can this be avoided?
I tried editing pg_hba.conf , restarting the server did not help.
pg_hba.conf :local all all trust
Answer the question
In order to leave comments, you need to log in
This has nothing to do with rubies.
The file associates the postgres user with the database
/etc/postgresql/9.X/main/pg_hba.conf
# TYPE DATABASE USER ADDRESS METHOD
local railshelloDB railshelloPG ident map=railshelloMAP
#local all railshelloPG ident map=railshelloMAP
# MAPNAME SYSTEM-USERNAME PG-USERNAME
railshelloMAP railshello railshelloPG
psql
Fair for Linux.
+ To connect (so as not to delve into pg_hba.conf ) It is
enough to specify host: localhost
. For example:
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: tester
password: tester
host: localhost # <- здесь или по месту в development, test
development:
<<: *default
database: awesome_development
CREATE ROLE username WITH LOGIN CREATEDB PASSWORD 'secret';
--- или
CREATE USER username WITH CREATEDB PASSWORD 'secret';
Enter your database settings (login-password-address-port) in database.yml, and then execute rake db:create in the project folder
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question