Search code examples
postgresqlpsqlpostgresql-15

psql cmd command using old user


I forgot my password for an older version of Postgres (I believe v14) and uninstalled it then deleted the remaining files in my program files folder.

I also deleted the environment variable in the path leading to it.

I installed the latest version, v15. I set the path variable to include C:\Program Files\PostgreSQL\15\bin

v15 works perfectly fine. When I do psql -U postgres I can log in.

None of my passwords work for it, I get

psql: error: connection to server at "localhost" (::1), port 5432 failed: FATAL:  password authentication failed for user "chris"

However, simply typing psql in the Power Shell asks me for an old user, of which I forgot the password (the above user, "chris").

PgAdmin does not have this user listed, nor any databases associated with it, only the new Postgres user with v15.


Solution

  • There probably is no user chris in your new v15 cluster. You'd have to create it:

    psql -U postgres
    ...
    postgres#> CREATE ROLE chris LOGIN;
    CREATE USER
    postgres#> \password chris
    Enter new password for user "chris":