阅读量:4
以下是在Ubuntu中配置PostgreSQL的步骤:
- 更新系统:打开终端,运行
sudo apt update和sudo apt upgrade,确保系统软件包最新。 - 安装PostgreSQL:使用命令
sudo apt install postgresql postgresql-contrib安装,postgresql-contrib包含额外功能模块,可根据需要选择安装。 - 启动服务并设置开机自启:安装后服务通常自动启动,可使用
sudo systemctl status postgresql检查状态,若未启动则用sudo systemctl start postgresql启动,再用sudo systemctl enable postgresql设置开机自启。 - 配置远程访问(可选):若需远程访问,编辑
/etc/postgresql/<版本>/main/postgresql.conf,将listen_addresses设为'*';编辑/etc/postgresql/<版本>/main/pg_hba.conf,添加如host all all 0.0.0.0/0 scram-sha-256的规则,然后重启服务sudo systemctl restart postgresql。 - 创建数据库和用户(可选):切换到
postgres用户sudo -i -u postgres,使用createuser --interactive创建新用户,用createdb创建数据库,再通过GRANT语句赋予权限。
以上就是关于“Ubuntu中PostgreSQL配置步骤”的相关介绍,筋斗云是国内较早的云主机应用的服务商,拥有10余年行业经验,提供丰富的云服务器、租用服务器等相关产品服务。云服务器资源弹性伸缩,主机vCPU、内存性能强悍、超高I/O速度、故障秒级恢复;电子化备案,提交快速,专业团队7×24小时服务支持!
简单好用、高性价比云服务器租用链接:https://www.jindouyun.cn/product/cvm