在CentOS 8/RHEL 8系统上安装PostgreSQL 11的方法
本文介绍在CentOS 8/RHEL 8操作系统上安装PostgreSQL 11的方法,CentOS 8/RHEL 8上正式维护的模块化存储库的PostgreSQL版本为10和9.6,我们将添加PostgreSQL Yum Repository,它包含所有最新版本。其实PostgreSQL项目为最常见的发行版提供了所有支持版本的软件包存储库,支持所有Red Hat系列,如CentOS、Fedora、Scientific Linux、Oracle Linux和Red Hat Enterprise Linux。
一、将PostgreSQL Yum存储库添加到CentOS 8/RHEL 8
PostgreSQL Yum存储库将与你的常规系统和补丁管理集成,并在PostgreSQL的整个支持生命周期内为所有受支持的PostgreSQL版本提供自动更新。
可以通过运行以下命令将其添加到CentOS/RHEL 8系统:
sudo dnf -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
查看软件包详细信息:
$ rpm -qi pgdg-redhat-repo
二、在CentOS 8/RHEL 8上安装PostgreSQL 11
禁用postgresql模块:
$ sudo dnf module disable postgresql
然后清理yum缓存并在CentOS 8/RHEL 8上安装PostgreSQL 11:
sudo dnf clean all
最后通过运行以下命令在CentOS 8/RHEL 8上安装PostgreSQL 11服务器和客户端软件包:
sudo dnf -y install postgresql11-server postgresql11
可以使用dnf命令检查次要版本详细信息:
$ dnf info postgresql11-server postgresql11
参考:在CentOS 7系统上安装PostgreSQL 11的步骤。
三、初始化数据库并启用自动启动
安装后,需要数据库初始化才能启动服务:
sudo /usr/pgsql-11/bin/postgresql-11-setup initdb
sudo systemctl enable --now postgresql-11
确认服务已启动且没有任何错误:
$ sudo systemctl status postgresql-11
PostgreSQL 11文件是:
/var/lib/pgsql/11/data/postgresql.conf
四、设置PostgreSQL管理员用户的密码
设置PostgreSQL管理员用户
$ sudo su - postgres
[postgres@rhel8 ~]$ psql -c "alter user postgres with password 'StrongPassword'"
ALTER ROLE
[postgres@rhel8 ~]$
创建测试用户和数据库:
[postgres@rhel8 ~]$ psql
psql (11.5)
Type "help" for help.
postgres-# createuser test_user
postgres-# alter user test_user with password 'MyDBpassword';
postgres=# createdb test_db -O test_user
postgres=# grant all privileges on database test_db to test_user;
GRANT
以test_user用户身份登录尝试在数据库上创建表:
$ psql -U test_user -h localhost -d test_db
至此,操作完成。
TAG:
除非注明,文章均由 Linux系统学习 整理发布,欢迎转载。如有版权争议,请联系删除。
转载请注明本文地址:http://8u.hn.cn/shujuku/12854.html,网络整理资料,转载时请保留原出处。
留言与评论(共有 0 条评论) |
文章评论