Rake db: create crash authentication problem with postgresql 8.4

First of all, please excuse my complete absence. I really tried to find a solution there, but now I am stuck and completely misunderstood.

I am trying to deploy a rails 3 application on a remote server; there were no problems when developing on my local virtual machine. But now when I try to run

rake db:create 

it fails, with an error (here it translates, since I'm French):

 FATAL : password authentication failed for user <<mylogin>> 

here is my database.yml:

 login: &login adapter: postgresql username: mylogin password: mypassword host: localhost port: 5432 encoding: UTF8 development: <<: *login database: somesite_development test: <<: *login database: somesite_test production: <<: *login database: somesite_production 

user "mylogin" was created by postgre-side using the createuser command-line tool. He allowed the creation of dbs. postgresql.conf configures the server to listen on localhost. I tried a lot of things with pg_hba.conf, nobody worked - regardless of the method used (identifier, password, md5) for the user "mylogin" at 127.0.0.1, authentication failed - although I never had problems connecting / creating dbs with psql.

any clue?

EDIT: alright, found out how incredibly stupid I was ... the password for my user is simply not set! I think I forgot the semicolon after

ALTER USER xxxx WITH PASSWORD xxxx;

... I saw this by querying "SELECT * FROM pg_shadow;" - the password field was blank. Three days of my life were wasted because of this dumb mistake ...

+6
source share
6 answers

ok, I found out how incredibly stupid I was ... the password for my user is simply not set! I think I forgot the semicolon after

 ALTER USER xxxx WITH PASSWORD xxxx ; 

... I saw this by querying "SELECT * FROM pg_shadow;" - the password field was blank. Three days of my life were wasted because of this dumb mistake ...

+2
source

I also lingered on this problem for a long time and went to various links (including those suggested in this post) to try to find the answer, but to no avail. However, the solution is very simple. Although many other answers were on the right track, here are the exact steps to solve the problem:

  • Open the pg_hba.conf file in a text editor of your choice. (It is in / etc / postgresql // main)

  • Go to the line that reads:

    # "local" is for Unix domain socket connections only

and paste it below:

  local all all trust 

This will trust all unix users trying to connect to the psql server on the local machine. (Read the documentation at the top of the page for more information on the column function)

  • Save the pg_hba.conf file and exit the text editor.

  • Restart the Postgresql server by running the command:

    postgresql restart service

  • Now try starting the psql server by doing:

    psql -d -U (or "psql" for short)

  • You can log in without a problem.

* Note: All of this assumes that you have a valid psql username for logging in. If you do not follow the links below to install one of them:

User Setup: http://erikonrails.snowedin.net/?p=274

Make sure you have a valid postgres user: http://archives.postgresql.org/pgsql-novice/2002-08/msg00072.php

List of all existing psql users: If you are looking for the "USERS USERS" or "USERS DISPLAY" command, try:

"select * from pg_user;" (upon entering psql)

Good luck

+19
source

I had the same problem. In my case, this happened because in my database.yml file the username began with a capital letter, but everything in the database was lowercase.

Solution: When creating a user from the postgres command line, it converts all letters to lowercase. To use capital letters, double quotation marks must be used.

Example:

create user AlbertEinstein; result = alberteinstein

against

create user "AlbertEinstein"; result = AlbertEinstein

+2
source

Here are some quick steps that should work for you.

http://www.cyberciti.biz/faq/psql-fatal-ident-authentication-failed-for-user/ .

Basically, you need to set the authentication method for localhost to "trust".

0
source

You need to grant "myuser" in postgresql the privilege "Can create database objects."

In pgadmin, it looks like this:

enter image description here

After calling rake db: create, you can revoke this privilege.

0
source

In my case, I found that the later line of the host permission rule in the pg_hba.conf exceeded the previous local line. I correctly configured the local string to use md5 authentication, but the host string was set to ident , which I changed to md5

As others emphasize, note that using trust is an unsafe method, so you should not use it in any production-style deployment.

0
source

Source: https://habr.com/ru/post/886863/


All Articles