createdb: could not connect to database postgres: FATAL: Peer authentication failed for user “postgres”


FATAL: Peer authentication failed for user “postgres”

Solution 1:
1.Add these to your database.yml file development and test environments?


host: localhost
port: 5432

2. rake db:create
3. rake db:migrate

Solution 2:

Still getting the issue try Altenative way

Error:
createdb: could not connect to database postgres: FATAL: Peer authentication failed for user “postgres”

So you have to create database from postgres command prompt:

In terminal create user of postgress

sudo -u postgres createuser --superuser $USER

Start the postgresql command prompt;

sudo -u postgres psql

At the postgresql prompt, set your password;
replace $USER with your username of which you want to set password

\password $USER

Run this command in postgresql command prompt to create database:

create database bauhaus_dev owner user_name;

Quit Terminal with ctrl+D and run this command in project root:

 bundle exec rake db:automigrate

above command will show this as result
[datamapper] Finished auto_migrate! for :default repository ‘database name’

It depicts that you are ready To Go 🙂

Now Run your rails server and start working.

To drop database in postgres commandline:

DROP DATABASE "bauhaus_production";
Advertisements

I am Senior Software Engineer. I love reading, writing, sharing,developing, hiking, movies, trips, mountains, brooks, hills etc.

Tagged with: , , ,
Posted in postgres

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

StackOverFlow
Categories
Archives
%d bloggers like this: