Setting up PostgreSQL (Ubuntu Linux) - Cannot connect, dont know password

Hello everyone,

I have just setup PostgreSQL on Ubuntu according to:

I am trying to connect to it using Postbird OR psql command line but I dont seem to know what the password is to connect.

I have followed these steps:

Create the file repository configuration:

sudo sh -c ‘echo “deb Index of /pub/repos/apt/ $(lsb_release -cs)-pgdg main” > /etc/apt/sources.list.d/pgdg.list’

# Import the repository signing key:
wget --quiet -O - | sudo apt-key add -

# Update the package lists:
sudo apt-get update

# Install the latest version of PostgreSQL.
# If you want a specific version, use ‘postgresql-12’ or similar instead of ‘postgresql’:
sudo apt-get -y install postgresql

And now started the Postgres server using the following command which seems to run successfully:

sudo pg_ctlcluster 14 main start

…however I am prompted to enter a password in Postbird or PSQL command line which I don’t recall setting up or seeing in these steps? Any help is greatly appreciated.


Ok, looks like you can use command line to switch to default postgres system user created by install:

sudo su - postgres

Then type this command:


Then you can just change the password using:


1 Like

Source: How To Install PostgreSQL 14 on Ubuntu 20.04 - howtodojo

Many super useful commands here that are not in the setup page. I think adding a step to explain how to connect and setup the user so Postbird can connect and allow the users to continue with the project would be super useful to people.

1 Like

Thank you!

I agree that this information should be in the course information.