Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9239793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:04:07+00:00 2026-06-18T08:04:07+00:00

Apparently this is a pretty hard question to ask because, simple as it is,

  • 0

Apparently this is a pretty hard question to ask because, simple as it is, no one seems to have answered it.

I have PostgreSQL running on ubuntu 12.10 server (no GUI).

My goal – my question – is to create a database named “mydb” and a user “admin” such that I can give this command as an ordinary user from the shell and connect to the database:

$ psql -U admin -d mydb

But I cannot find the answer to this anywhere.

I can log in as user postgres by su’ing and running the psql command:

$ sudo su -m postgres
postgres@baseubu1210dev:~$ psql
psql (9.1.7)
Type "help" for help.

postgres=# 

I have figured out how to create a database named “mydb” and a user “admin” such that:

postgres=# \du
 Role name |                 List of roles Attributes       | Member of 
-----------+------------------------------------------------
 admin     | Superuser, Create role, Create DB              | {}
 postgres  | Superuser, Create role, Create DB, Replication | {}

I have not figured out how to make sure that user “admin” can connect to the “mydb” database – perhaps someone with such privileges doesn’t need to? [As I write, I notice that I should probably revoke Superuser privileges from admin.]

And what I really want to know is how to connect from a regular user’s shell:

$ psql -U postgres
psql: FATAL:  Peer authentication failed for user "postgres"

There are surely unwritten assumptions about running postgreSQL that I’m misunderstanding, but a couple of hours of searching, looking at tutorials, etc., has not solved the problem. I’ll be perfectly happy if someone says this has already been answered, especially if it has. I assume and hope that the answer is simple and appreciate your help.

Thanks,
ge

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:04:09+00:00Added an answer on June 18, 2026 at 8:04 am

    From the error-message, it seems that the authentication-settings have not been properly set.

    Besides the settings in the database itself, PostgreSQL also uses a configuration file (pg_hba.conf) that specifies what authentication-mechanisms can be used per user, host and database. You can specify that users can only connect via password/md5 password or even ‘no authentication required’

    Currently your configuration probably uses ‘Peer’ authentication for all users, which simply means: Only allow that user if it is the currently logged-in user (e.g. your shell-user should also be called ‘admin’). From your question, this is not what you want, you’ll probably want to use password or md5 authentication mechanism.

    I think these pages will give you the answer you need:

    http://web.archive.org/web/20131001194046/http://blog.deliciousrobots.com/2011/12/13/get-postgres-working-on-ubuntu-or-linux-mint/ (archived version)

    Official documentation:

    http://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html

    Remember to reload postgresql after modifying the pg_hba.conf file!

    update

    The original blog-post I referred to is now offline, the link now points to an archived version. Thanks to @O_the_Del for reporting.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems like it should be pretty straight forward, but I'm apparently confused. I
I thought this would be pretty simple but apparently it isn't, at least not
This is my question and apparently this is the answer . Turns out it
C++98 apparently has this as one of the standards for compilation phases. What does
I have this sql: ALTER TABLE dbo.ChannelPlayerSkins DROP CONSTRAINT FK_ChannelPlayerSkins_Channels but apparently, on some
Pretty simple question. I've seen it mentioned in many places that using properties on
I have C headers which forward declare enums. Apparently, this is not possible in
I came across this error that is apparently pretty common among Linux Systems. Too
So not sure if this is possible but I have a pretty complex form.
I have a pretty simple form. When the user types in an input field,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.