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
pg_hba.conf
, and show the exact text of the newdatabase.rb
as well as the old one.localhost
your pg installation needs to be accepting TCP/IP connections. Look up the listen_addresses parameters inpostgresql.conf
: it is commented out by default but you need to enable it. Then inpg_hba.conf
you need to have at least one line to indicate that connections to databases over TCP/IP are allowed, using thetrust
authentication method (i.e. no passwords supplied). SIGHUP the server to read the new configuration withpg_ctl reload
.