当PostgreSQL安装完成后,咱们进行如下操做sql
su - _postgresql initdb -D /var/postgresql/data -U postgres -E UTF8 -A md5 -W
以后咱们须要配置自动启动shell
OpenBSD 5.6版本工具
配置自动启动rc.localpost
if [ -x /usr/local/bin/pg_ctl ]; then echo -n ' postgresql' su -l _postgresql -c "nohup /usr/local/bin/pg_ctl start \ -D /var/postgresql/data -l /var/postgresql/logfile \ -o '-D /var/postgresql/data' > /dev/null" fi
配置自动中止postgresql
if [ -f /var/postgresql/data/postmaster.pid ]; then su -l _postgresql -c "/usr/local/bin/pg_ctl stop -m fast \ -D /var/postgresql/data" rm -f /var/postgresql/data/postmaster.pid fi
OpenBSD 5.7版本
code
在rc.conf.local中添加ip
pkg_scripts=postgresql
或使用新的rcctl工具md5
rcctl enable postgresql