FreeBSD安装postgresql

发布时间:2024年01月16日

安装postgresql15

$ sudo pkg install postgresql15-server postgresql15-client

# 安装完之后会自动注册到服务列表
root@freebsd14-11-199:~ # service -l|grep post
postgresql
# 将postgresl添加到开机自启动
root@freebsd14-11-199:~ # service -e|grep post
root@freebsd14-11-199:~ # sysrc 'postgresql_enable=YES'
postgresql_enable: ?-> YES
root@freebsd14-11-199:~ # service -e|grep post
/usr/local/etc/rc.d/postgresql

初始化数据库

root@freebsd14-11-199:~ # /usr/local/etc/rc.d/postgresql initdb
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

……

Success. You can now start the database server using:

? ? /usr/local/bin/pg_ctl -D /var/db/postgres/data15 -l logfile start

修改将5432端口绑定到*上而不是默认的localhost
root@freebsd14-11-199:/var/db/postgres/data15 # vi postgresql.conf?
#listen_addresses = 'localhost' ? ? ? ? # what IP address(es) to listen on;
listen_addresses = '*' ? ?
新增一条允许远程登录策略
root@freebsd14-11-199:/var/db/postgres/data15 # vi pg_hba.conf?
# IPv4 local connections:
……
host ? ?all ? ? ? ? ? ? all ? ? ? ? ? ? 0.0.0.0/0 ? ? ? ? ? ? ? md5?

启动并验证

root@freebsd14-11-199:~ # ?service postgresql start
2002-02-04 19:05:52.238 CST [10417] LOG: ?ending log output to stderr
2002-02-04 19:05:52.238 CST [10417] HINT: ?Future log output will go to log destination "syslog".
root@freebsd14-11-199:~ # service postgresql status
pg_ctl: server is running (PID: 10417)
/usr/local/bin/postgres "-D" "/var/db/postgres/data15"

文章来源:https://blog.csdn.net/avatar_2009/article/details/135629364
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。