1

Im having some problems with my postgresql server. In particular, some databases cannot be dropped.

On further inspection, I see that the postgres user is not a SuperUser.

There are two other users that are super users:

  • pgsql
  • s6cefdco

However I do have the password for these.

How can I make postgres a SuperUser again?

The operating system is CentOs.

I have tried the following:

sudo -u postgres postgres --single /var/lib/pgsql/9.6/data

Which results in

sudo: postgres: command not found
NO WAR WITH RUSSIA
  • 54,954
  • 34
  • 200
  • 411
Magick
  • 111
  • 1
  • 4

2 Answers2

1

Try running this,

sudo -u postgres dropdb myDatabase
NO WAR WITH RUSSIA
  • 54,954
  • 34
  • 200
  • 411
  • I've tried `service postgresql-9.6 stop` and then `dropdb mds` but I'm prompted for a password. Im not sure why. I'm logged in as root, but there is no password - I login using ssh key. – Magick Jan 12 '18 at 06:40
  • So ignore the service part and just run the above command – NO WAR WITH RUSSIA Jan 12 '18 at 16:03
1

How can I make postgres a SuperUser again?

A user is made superuser by executing:

  ALTER USER nameofuser SUPERUSER;

It must be executed by another superuser. The question says there are two accounts that are superuser and you do have their passwords, so you should be able to log in with one of them and just issue that SQL command.

If you didn't know these passwords, you could still log in bypassing the password by temporarily changing pg_hba.conf. How to do that is a frequently asked question, see for instance: remove password requirement for user postgres .

Daniel Vérité
  • 26,604
  • 3
  • 60
  • 69