16

Hey so after I ran into somes issues I decided to uninstall Postgres and re-install it (re install a newer version btw).

I'm trying to access postgres to create a new db for my Rails app so I run su postgresor su _postgres then I am asked a password but nothing that I enter works.

So I tried sudo -u postgres psql and got

sudo: unknown user: postgres
sudo: unable to initialize policy plugin

I tried also to disable SIP (see: here)

but it didn't work either. same results.

I don't know what to do. Any idea ? I am using Mac OS High Sierra 10.13.6.

6
  • What about sudo -u _postgres psql? Commented Sep 22, 2018 at 17:25
  • thank you @GordonDavisson the password works ! however, I then get: psql: FATAL: role "_postgres" does not exist. What's wrong ? Commented Sep 22, 2018 at 17:28
  • Try: psql -u postgres Commented Sep 22, 2018 at 18:02
  • @wildplasser thank you for you help; it says psql: invalid option -- u Commented Sep 23, 2018 at 6:45
  • Oops, that should have been a capital U: psql -U postgres Commented Sep 23, 2018 at 10:48

3 Answers 3

39

Thanks to @gordon Davidson and @wildplasser 's help, I found the solution:

sudo -u myusername psql postgres
Sign up to request clarification or add additional context in comments.

4 Comments

alternatively: psql -U myusername -d postgres without the need for sudo
I am having the same error, Could you please help me what i am suppose to do right? sudo: unknown user: postgres sudo: unable to initialize policy plugin
@MushahidKhan did you run the above mentionned command to try and solve your issue ?
@JulesCorb, obvious, i tried , but not table to log in, working on it, hopefully will get some solution
3

I had this same challenge when trying to access a PostgreSQL database.

When I run the command below:

sudo -u postgres psql

I get the error below:

sudo: unknown user: postgres
sudo: unable to initialize policy plugin

The issue was that I did not have the PostgreSQL database server installed on the server. The server only had a MySQL database server set up on it.

That's all.

I hope this helps

Comments

0

From your EC2 node issue the following command to test if database is reachable.

/opt/gitlab/embedded/bin/psql -U YourExistingUsername -d template1 -h AWS-RDS-POSTGRES-ENDPOINT

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.