What I did:
sudo -u postgres psql
CREATE ROLE shop CREATEDB LOGIN PASSWORD 'kurt1245';
Then I cloned a repository from GitHub (a rails application which uses pg), bundle install
, edit database.yml
to write my password and now after rake db:create
(also setup
and migrate
) doesn't work.
database.yml
:
development:
adapter: postgresql
encoding: unicode
database: shop_development
pool: 5
username: shop
password: kurt1245
test:
adapter: postgresql
encoding: unicode
database: shop_test
pool: 5
username: shop
password: kurt1245
Please Add host to your database.yml file. Hope it will help you.
development:
adapter: postgresql
encoding: unicode
host: localhost
database: shop_development
pool: 5
username: shop
password: kurt1245
test:
adapter: postgresql
encoding: unicode
host: localhost
database: shop_test
pool: 5
username: shop
password: kurt1245
I've had the same error a few days back.
Edit the /etc/postgresql/$version/main/pg_hba.conf
You can check what version you're using in the psql console as select VERSION();
Inside pg_hba.conf
change
local all postgres peer
to:
local all postgres md5
Peer Authentication explained
19.3.7. Peer Authentication
The peer authentication method works by obtaining the client's operating system user name from the kernel and using it as the allowed database user name (with optional user name mapping). This method is only supported on local connections.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With