laughinl
laughinl

Reputation: 13

Can't access superuser in postgresql

I can't seem to access my superuser account for my posgresQL database.

Using the command:

psql -U postgres

I sucessfully login into the user 'postgres'. However, this is not the default superuser. Doing:

=# \du

I get:

List of roles
 Role name |             Attributes              | Member of 
-----------+-------------------------------------+-----------
pgsql     | Superuser, Create DB                | {}
postgres  | Create role, Create DB, Replication | {}

So 'pgsql' appears to be my default superuser.

When trying:

psql -U pgsql

I get the following error:

psql: FATAL:  database "pgsql" does not exist

I changed the pg_hba.conf file to the following:

# Database administrative login by Unix domain socket
local   all             all                                trust

and also tried:

# Database administrative login by Unix domain socket
local   all             pgsql                                trust

but I still get the same error regardless, that database 'pgsql' does not exist.

Any help would be greatly appreciated, I need to be able to access the database's superuser.

Upvotes: 1

Views: 5703

Answers (1)

Vao Tsun
Vao Tsun

Reputation: 51649

just define database:

psql -U pgsql -d postgres

if you get error that postgres database does not exist, connect as postgres and list databases with \l

Upvotes: 1

Related Questions