2

While accesing postgres database i got an error saying

FATAL:  Peer authentication failed for user "myuser"

to resolve this error i need to change the database owner like

ALTER DATABASE dbname OWNER TO 'all';

all is not a user in my system, but i want to make this database available to all the user in the system.

I am sure there is way to do stuff like this. can any one help me!

3 Answers 3

2

You need to read the Client Authentication section of the manual, particularly the part that discusses pg_hba.conf. PostgreSQL's manual and tutorials are fairly comprehensive and are well worth a read.

There are lots of questions on Stack Overflow, superuser.com, serverfault.com and dba.stackexchange.com that cover pg_hba.conf so I won't repeat what's already available in abundance.

Very short version:

  • Use md5 authentication; and
  • CREATE USER all the users you want to be able to log in or have them all log in as a shared identity.

Please read the manual sections on authentication and security to avoid future pain and problems.

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

Comments

1

In your file system find pg_hba.conf file using

locate pg_hba.conf

Then find the version of your postgres.

edit the file using

sudo nano /etc/postgresql/9.1/main/pg_hba.conf

If you have the following line:

local   all    all     peer

then change it to:

local   all    all     md5

I am sure it will work!

Comments

0

Peer authentication means that PostgreSQL will only allow the OS user, admin, to connect as admin, or the OS user myuser to connect to PostgreSQL as myuser.

This is because it has an entry in the pg_hba.conf file like this

local   all    all    peer

If you replace it with this

local   all   all    trust

then all users on the same OS that hosts the PostgreSQL database will be able to connect freely.

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.