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

  • Home
  • SEARCH
  • 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 9206013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:05:13+00:00 2026-06-18T00:05:13+00:00

In Ubuntu, I installed PostgreSQL database and created a superuser for the server. If

  • 0

In Ubuntu, I installed PostgreSQL database and created a superuser for the server.

If I forgot the password of the postgresql superuser, how can I reset it (the password) for that user?

I tried uninstalling it and then installing it again but the previously created superuser is retained.

  • 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-18T00:05:14+00:00Added an answer on June 18, 2026 at 12:05 am

    Assuming you’re the administrator of the machine, Ubuntu has granted you the right to sudo to run any command as any user.
    Also assuming you did not restrict the rights in the pg_hba.conf file (in the /etc/postgresql/9.1/main directory), it should contain this line as the first rule:

    # Database administrative login by Unix domain socket  
    local   all             postgres                                peer
    

    (About the file location: 9.1 is the major postgres version and main the name of your "cluster". It will differ if using a newer version of postgres or non-default names. Use the pg_lsclusters command to obtain this information for your version/system).

    Anyway, if the pg_hba.conf file does not have that line, edit the file, add it, and reload the service with sudo service postgresql reload.

    Then you should be able to log in with psql as the postgres superuser with this shell command:

    sudo -u postgres psql
    

    Once inside psql, issue the SQL command:

    ALTER USER postgres PASSWORD 'newpassword';
    

    In this command, postgres is the name of a superuser. If the user whose password is forgotten was ritesh, the command would be:

    ALTER USER ritesh PASSWORD 'newpassword';
    

    References: PostgreSQL 9.1.13 Documentation, Chapter 19. Client Authentication

    Keep in mind that you need to type postgres with a single S at the end

    If leaving the password in clear text in the history of commands or the server log is a problem, psql provides an interactive meta-command to avoid that, as an alternative to ALTER USER ... PASSWORD:

    \password username
    

    It asks for the password with a double blind input, then hashes it according to the password_encryption setting and issue the ALTER USER command to the server with the hashed version of the password, instead of the clear text version.

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

Sidebar

Related Questions

After I installed PostgreSQL 9.1 on Ubuntu 12.04 I set the password for the
I have recently installed PostgreSQL on Ubuntu with the EnterpriseDB package. I can connect
I've installed Ubuntu Server (8.04) into Parallels and found that the system time/clock ran
I installed Ubuntu, GlassFish web server, installed JRuby on Rails using GlassFish's admin tools,
I want to install gcc-4.3 but it's not installed in Ubuntu 11.10. How can
I have installed PostgreSQL and pgAdminIII on my Ubuntu Karmic box. I am able
I just installed Ubuntu and tried making the famed Hello World program to make
New install of PostgreSQL and pgAdmin on Ubuntu 11.04 64-bit. On restoring a database
I have just installed Ubuntu. I am a new user to ubuntu but have
I'm using Ubuntu 10.10, PostgreSQL 9.0 and PostGIS 1.5. I've installed PostGIS 1.5 from:

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.