Setting up PostgreSQL

Installation & startup

netbsd

echo $PKG_PATH
pkg_add postgresql12
cp /usr/pkg/share/examples/rc.d/pgsql /etc/rc.d/
echo pgsql=yes >> /etc/rc.conf
/etc/rc.d/pgsql start

from source (slackware)

groupadd -g 209 postgres
useradd -u 209 -g 209 -d /var/lib/postgres postgres
mkdir /var/lib/postgres/
chown postgres:postgres /var/lib/postgres/
mkdir /var/log/postgres/
chown postgres:postgres /var/log/postgres/

grab and build the latest release

wget https://ftp.postgresql.org/pub/source/v13.0/postgresql-13.0.tar.gz
tar xzf postgresql-13.0.tar.gz
cd postgresql-13.0/

./configure --prefix=/usr/local
make
make install

/usr/local/bin/postgres -V

su - postgres
initdb -D /var/lib/postgres
#--auth-local --auth-host
pg_ctl -D /var/lib/postgres -l /var/log/postgres/postgres.log start
^D

ps auxfww | grep postgres

sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"
sudo -u postgres psql -c "CREATE DATABASE testdb;"

Ready to go

at boot time

vi /etc/rc.d/rc.local

chsh -s /bin/ksh postgres
su -c '/usr/local/bin/pg_ctl -D /var/lib/postgres -l /var/log/postgres/postgres.log start' - postgres
chsh -s /sbin/nologin postgres 2>/dev/null

status

echo POSTGRES
ps auxfww | grep postgres | grep -v grep
echo

stop

chsh -s /bin/ksh postgres
su - postgres
/usr/local/bin/pg_ctl -D /var/lib/postgres stop
^D

Ready to go

netbsd

    createdb -e -h 127.0.0.1 -U pgsql nobudget
    psql -U pgsql nobudget

slackware

createdb -e -h 127.0.0.1 -U postgres nobudget
    psql -U postgres nobudget

Resources

https://wiki.netbsd.org/pkgsrc/how_to_install_a_postgresql_server/

https://slackbuilds.org/repository/14.2/system/postgresql/

https://tableplus.com/blog/2018/10/how-to-start-stop-restart-postgresql-server.html

https://stackoverflow.com/questions/32013772/how-to-find-out-if-a-directory-is-a-valid-postgresql-cluster

https://stackoverflow.com/questions/30328374/cannot-connect-to-template1-fatal-role-postgres-does-not-exist

https://www.postgresql.org/docs/8.2/tutorial-createdb.html

ops

https://www.postgresql.org/docs/9.1/server-start.html

migrate

https://pgloader.readthedocs.io/en/latest/ref/pgsql.html

scalable

https://www.quora.com/Is-PostgreSQL-a-distributed-and-scalable-database


HOME | GUIDES | BENCHMARKS | html