Search code examples
postgresqlpermissionsrole

postgresql data directory not connecting


I am using windows 8. My Postgres was Correct. I just took the data directory from C:/postgresql/8.3/ Now database was connected through command prompt. When I was trying to connect using pgadmin, it's saying

FATEL: error
An error has occured:
Error connecting to sthe server: FATAL: role "postgres" is not permitted to log in

I changed the required things in pg_hba.conf (trust) and postgresql.conf (connection *) (port 5433)

But, still I was unable to connect the database.

How to give the permissions to postgres role. when am trying to give the permissions through cmd also it's giving same error.

I was tried in so many ways but, still I didn't get the database.


Solution

  • It looks like you might have accidentally revoked the LOGIN and SUPERUSER rights from the postgres user. Perhaps you created a superuser with a different name instead? Log in as that user if you did.

    If not, and you can't get access as user postgres, you will need to start the database engine up in single-user mode and manually GRANT the SUPERUSER right to postgres again. This is much the same process as is required when recovering from a dropped (deleted) superuser account.

    See related:

    BTW, 8.3 is a very old and unsupported version. Plan your upgrade promptly.

    If there's no data in PostgreSQL that you care about, the easiest thing to do will be:

    • Uninstall PostgreSQL 8.3;
    • Delete C:\Program Files\PostgreSQL\8.3 (permanently and unrecoverably destroying all data in your PostgreSQL databases); and
    • Install a current PostgreSQL version