'brew pin does not prevent upgrading of postgresql formula
I am trying to prevent my current version of posgtgresql being upgraded. Accordingly I did brew pin postgresql@12. However I am finding that if I do
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
I get the following error message
waiting for server to start.... stopped waiting
pg_ctl: could not start server
Examine the log output.
Looking at the log output, the last lines are
2022-05-01 17:31:00.816 AEST [18650] FATAL: database files are incompatible with server
2022-05-01 17:31:00.816 AEST [18650] DETAIL: The data directory was initialized by PostgreSQL version 12, which is not compatible with this version 14.2.
so postgresql has been updated to version 14.2.
If I do brew list --pinned it shows
postgresql@10
postgresql@11
postgresql@12
so I am still have postgresql@12 pinned. So why has the pinning not worked, and how do I restore posgresql to version 12?
I notice that if I do brew services list I see
postgresql none
postgresql@10 none
postgresql@11 none
postgresql@12 error 6 Chris ~/Library/LaunchAgents/[email protected]
i.e. postgresql@14 is not listed, so perhaps postgresql was upgraded in some other manner than using brew? However, I certainly did not do explicit upgrade, so do not see how this could have happened.
Solution 1:[1]
In lieu of an answer to this question, the way I recover from this situation is explained in this SO answer.
In brief (warning this destroys the databases)
brew uninstall --force postgresql
brew install postgresql@12
cd /usr/local/var/
rm -rf postgres
initdb /usr/local/var/postgres
Trying to look on the bright side, it is an opportunity to upgrade your databases by either a minor or major version.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Obromios |
