export VERSION=15
port info postgresql${VERSION}-server
port install postgresql${VERSION}-server
sudo mkdir -p /opt/local/var/db/postgresql${VERSION}/defaultdb
sudo chown postgres:postgres /opt/local/var/db/postgresql${VERSION}/defaultdb
sudo su postgres -c 'cd /opt/local/var/db/postgresql${VERSION} && /opt/local/lib/postgresql15/bin/initdb -D /opt/local/var/db/postgresql15/defaultdb'
change the port
in /opt/local/var/db/postgresql${VERSION}/defaultdb/postgresql.conf
This seems to be broken => manual start, see below
port unload postgresql12-server
port load postgresql12-server
see also https://guide.macports.org/chunked/reference.startupitems.html#reference.startupitems.
/Library/LaunchDaemons/org.macports.postgresql12-server.plist
/opt/local/etc/LaunchDaemons/org.macports.postgresql12-server/postgresql12-server.wrapper
as user postgres
, e.g. sudo -i -u postgres
/opt/local/lib/postgresql${VERSION}/bin/pg_ctl -D /opt/local/var/db/postgresql${VERSION}/defaultdb start -l /opt/local/var/log/postgresql${VERSION}/postgres.log
for version 10 pg server:
oneliner:
sudo -u postgres /opt/local/lib/postgresql10/bin/pg_ctl -D /opt/local/var/db/postgresql10/defaultdb start -l /opt/local/var/log/postgresql10/postgres.log
/opt/local/lib/postgresql10/bin/pg_ctl -D /opt/local/var/db/postgresql10/defaultdb start -l /opt/local/var/log/postgresql10/postgres.log
/opt/local/lib/postgresql13/bin/pg_ctl -D /opt/local/var/db/postgresql13/defaultdb -l /opt/local/var/log/postgresql13/postgres.log start
initially also as user postgres
CREATE USER tom WITH SUPERUSER LOGIN PASSWORD 'tom';
CREATE DATABASE tom owner tom
@DrTom Thanks for taking time to document this. I would like to point out a typo in 'Install' section. You missed out on 'l' in 'port install postgresq${VERSION}-server'