I installed postgres 9.5 quite a while ago, and since a few months ago have upgraded to 9.6 and used that. Recently I shut down my computer and restarted postgres, but when I connect to the 9.6 server and run
SHOW data_directory
it is showing that my data directory is under the 9.5 folder. As a result, none of my recent databases are available because I am linked to the old version of postgres. What happened and how can I change it back?
It would seem that your machine has started your previous instance. You need to stop the 9.5 server and start the 9.6.
On *nix OS you will need to use the PG_CTL command. eg:
PG_CTL -D [enter path for 9.5 data directory here] stop
PG_CTL -D [enter path for 9.6 data directory here] start
This should stop 9.5 and start 9.6. You can confirm this by doing:
PG_CTL -D [enter path for 9.5 data directory here] status
should return stopped.
PG_CTL -D [enter path for 9.6 data directory here] status
should return running.