0
votes

I am new to postgres and facing difficulty in connecting to DB after server reboot. I have created a database pgdb under an OS user test. After Server restarted, I restarted pgsql by issuing the command

service postgresql-9.6 start

Starting postgresql-9.6 service: [ OK ]

If i just issue psql, I am taken to psql prompt but the data path here is different than what I have set previously. When I try to connect to pgdb as postgres user, I get the error:

psql: FATAL: database "pgdb" does not exist

When I try to connect as Test user:

psql -d pgdb

psql: FATAL: role "test" does not exist

Please suggest

1
Why do You use few version tags? How is Your problem specific only to particular version?Michas
The error message seems pretty clear. There is no database user named test.a_horse_with_no_name

1 Answers

0
votes

It sounds like the database you created under the OS user test is under a different instance of Postgres than the instance that was instantiated by service postgresql-9.6 start. The two instances could be (or could have been, before the server restarted) running under different ports (eg, 5432 and 5433).

Or, since you have this tagged as both postgres-9.4 and postgres-9.6, you need to be aware that they are distinct from each other. Any database you created under Postgres 9.4 should not be expected to exist under Postgres 9.6. If you created the pgdb database under 9.4, but after the reboot, began running 9.6, you generally would need to migrate the db (the procedure for which is beyond the scope of this question). Likewise, a user created under 9.4 would not automatically exist under 9.6.