Lost access to postgres, how to start over



I seemed to have locked myself out of postgres:

esend7881:~ $ sudo -u postgres psql
[sudo] password for ubuntu: 
Sorry, try again.

Luckily I am just starting out. How do I “wipe the slate clean” and start over with postgres, putting everything back to default?


the ubuntu user has sudo access to do things as root, but not as postgres; but the root user can.

Linux sudo permissions can be confusing, but try this:

sudo su postgres -c psql


sudo sudo -u postgres psql

I’ve already made a fix to have psql work as the default user, it’ll be getting released in the next couple weeks.


Oh I see what was happening. The sudo command was asking me for the ubuntu password. When I did:

sudo bash

First, it bypassed it. I wonder why it didn’t want my password when I did sudo bash though.

So although that worked, it appears my postgres isn’t doing much:

esend7881:~ $ sudo bash
esend7881:~ $ sudo -u postgres psql
psql (9.3.10)
Type "help" for help.

postgres=# createuser eric
postgres-# creaasdfadsf
postgres-# help
postgres-# "help"

I wonder if the issues are related.


If you don’t specify a user, sudo will try to do things as root. The ubuntu user on C9 is set up to allow passwordless SSH as root user. Sudo doesn’t differentiate between root/postgres/etc users; you have permissions to sudo to root ONLY so trying to sudo to postgres user acts as though you don’t have permissions (i.e. ask for password then deny anyway).