What is the Default Password for PostgreSQL?

Cpanel/Whm License $3/mo Plesk License $10/mo Cloudlinux License $5/mo

When connecting to PostgreSQL on Linux for the first time many admins have questions, especially if those admins are from the MySQL world. By default, when PostgreSQL is installed, a postgres user is also added.

If you run the command:

cat /etc/passwd

… you’ll see the postgres user.

postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash

 

The first question many ask is, “What is the default password for the user postgres?” The answer is easy… there isn’t a default password. The default authentication mode for PostgreSQL is set to ident.

cat /var/lib/pgsql/9.3/data/pg_hba.conf

… you’ll see the authentication mode is ident.

# IPv4 local connections:
host    all              all             127.0.0.1/32             ident
# IPv6 local connections:
host    all              all             ::1/128                  ident

What is the ident authentication method? Well, it works by taking the OS username you’re operating as and comparing it with the allowed database username(s). There is optional username mapping.

This means that in order to connect to PostgreSQL you must be logged in as the correct OS user. In this case, we are logged into the server as root. When we try to connect to PostgreSQL:

psql

… we get the following error:

psql: FATAL: role "root" does not exist

However, if we become the default PostgreSQL user, postgres:

su - postgres

… then attempt a connection to PostgreSQL:

psql

… I get the correct, valid response!

psql (9.3.9)
Type "help" for help.

postgres=#

Is your Cloud VPS slowing down your PostgreSQL instance? sxi.io Web’s Dedicated Servers is the solution. sxi.io Web’s server outmatches the competition on performance and support. Check out how our Dedicated Servers can skyrocket your site’s performance.

Related posts

OECD: ICOs Have Financing Benefits But Aren’t a Mainstream Option

SXI ADMIN

3 Tips For Working With a MySQL Database!

SXI ADMIN

US State Bank Supervisors to Discuss Bitcoin at Public Hearing

SXI ADMIN

Linux / UNIX FTP Commands Tutorial

SXI ADMIN

Who Watches Bitcoin’s Watchmen? Scaling’s Great Game of Egos

SXI ADMIN

EU Watchdog: Blockchain Security Should Be Concern For Finance Firms

SXI ADMIN

Use virt-manager as a non-root user on Linux

SXI ADMIN

European Commission Hosts Blockchain Workshop with Industry Focus

SXI ADMIN

Google provides self-explanatory Knowledge Panel for brands

SXI ADMIN

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More