I've deleted database from PostgreSQL and after this I can do nothing.
Here what i receive with createuser
$ createuser -D new_user
createuser: could not connect to database postgres: FATAL: role "postgres" does not exist
And this when try to run psql
$ psql
psql: FATAL: role "postgres" does not exist
I've tried above with root
, postgres
, custom
users. Still same output
Also I searched for pg_hba.conf
like this
find / -name 'pg_hba.conf'
and got this
/var/lib/postgres-xc/DN2/pg_hba.conf
/var/lib/postgres-xc/DN1/pg_hba.conf
/var/lib/postgres-xc/CN/pg_hba.conf
/etc/postgres-xc/coordinator/CN/pg_hba.conf
/etc/postgres-xc/datanode/DN2/pg_hba.conf
/etc/postgres-xc/datanode/DN1/pg_hba.conf
/etc/postgresql/9.3/main/pg_hba.conf
I've changed connection method to trust
for localhost
and IPv4
in /etc/postgresql/9.3/main/pg_hba.conf
.
What should I do get rid of this error?
Does connection method in other files above should be edited too?
Best Answer
Main problem was that I could not run
psql
command under no user. Output I received was:any role
means that I tried to runpsql
under each user on my system(root
,postgresql
,my_user
)After all I haven't figured out what the problem was, I decided to reinstall PostgreSQL.
And this process turned out rather hard to.
So if you have problems with deleting and reinstalling PostgreSQL, read on.
Here what I had to do.
echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list
sudo apt-get update
now we get error about missing
postgresql-common
to fix it we need to install above package lets determine its versionand install it
we can get error that
postgresql-client-common
not installed so we need to do the same determine it versionand install
after this we can install postgresql like this