`psql` on Terminal To get to the PostgreSQL terminal, open your terminal, start the database services ( brew services start postgresql) , then run psql . Thank you!
psql -c "SELECT 1" -d {dbname} > /dev/null || postgres -D /usr/local/var/postgres >postgres. log 2>&1 & if you want to check and start postgres in one go (handy for automation scripts).
Just in case postgres has been installed using homebrew, you can also run below command:
brew services restart postgres
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log restart
/usr/local/var/postgres
is the location of the database storage area, and /usr/local/var/postgres/server.log
is my log file for postgres. The last word restart
is the operative word here. You can also use start
to start the service.
You can find the location of the database storage area by running ps aux | grep postgres | grep -- -D
for hba.conf
changes to apply you don't need to restart - just reload.
run select pg_reload_conf()
in psql
also:
run show data_directory
in psql to find your data dir...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With