PostgreSQL accidentally update from Homebrew — OSX
Error:
Django PostgreSQL Is the server running on host “localhost” (127.0.0.1) and accepting TCP/IP connections on port 5432?
After installing some tools from homebrew, I was just surprised that my PostgreSQL has been updated. And when I start the PostgreSQL and run python manage.py runserver it gives me output: django.db.utils.OperationalError: FATAL: role “databaseA” does not exist
I tried to make sure that the PostgreSQL has the previous data
$ /usr/local/Cellar/postgresql/13.1/bin/pg_ctl -D /usr/local/var/postgres start
and it gave me output: The data directory was initialized by PostgreSQL version 12, which is not compatible with this version 13.1. pg_ctl: could not start server
Solutions:
$ brew uninstall postgresql or brew uninstall — ignore-dependencies postgresql
$ brew install postgresql@12
if you face “LOG: could not bind IPv6 address “::1”: Address already in use” try to see
$ ps auxw | grep post
$ kill -9 <PID>Then Run
$ /usr/local/Cellar/postgresql@12/12.5/bin/pg_ctl -D /usr/local/var/postgres start
Hope this helps!