0

the first time when postgresql is installed in my local machine i created a user "user1" using the following command :

$ sudo su postgres -c psql
postgres=# CREATE ROLE user1 SUPERUSER LOGIN;
postgres=# \q

then setup my database.yml

development:
  adapter: postgresql
  encoding: unicode
  database: appname_development
  pool: 5
  timeout: 5000
  username: user1
  password:

and all work fine, so today i created a new app then i did the same steps (creating a new user "user2" and modify my database.yml)

development:
  adapter: postgresql
  encoding: unicode
  database: application2_development
  host: localhost
  pool: 5
  timeout: 5000
  username: user2
  password: 

but when i try to create the database

$ rake db:create:all

i get this error :

FATAL:  Peer authentication failed for user "application2"

i tried to fix the problem by adding host: localhost to my database.yml but now i get another error which is :

fe_sendauth: no password supplied

can someone explains to me what means this error, and why the first time when i created the first user it doesn't show me this error ? then i will be thankful to know the solution as well.

thank you

3
  • Show the contents of your pg_hba.conf, and show the exact text of the new database.rb as well as the old one. Commented Mar 22, 2014 at 4:49
  • ok i added my database.yml but pg_hba.conf is empty Commented Mar 22, 2014 at 5:04
  • If you connect through localhost your pg installation needs to be accepting TCP/IP connections. Look up the listen_addresses parameters in postgresql.conf: it is commented out by default but you need to enable it. Then in pg_hba.conf you need to have at least one line to indicate that connections to databases over TCP/IP are allowed, using the trust authentication method (i.e. no passwords supplied). SIGHUP the server to read the new configuration with pg_ctl reload. Commented Mar 22, 2014 at 7:01

1 Answer 1

0

I have already faced this problem and fixed it.

I think, It will be helpful to you.

please find 'pg_hba.conf' and postgresql.conf files.

generally, pg_hba.conf and postgresql.conf files located at /etc/postgresql/9.1/main/.

put `local all all md5' in pg_hba.conf and save it.

open postgresql.conf file and if listen_addresses = 'localhost' and port = 5432 line are commented. then uncomment to it.

Finally restart to pg server and try to create database.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.