linux 安装PostgreSQL

把最新的rpm包添加到系统库PostgreSQL会为所有的Linux平台发布rpm包, 而且会比其他的的库更新的更快.地址:postresSQL linuxrpm -Uvh https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm

列出可用安装包yum list postgres*

安装PostgreSQLyum install -y postgresql11-server.x86_64

初始化数据库/usr/pgsql-11/bin/postgresql-11-setup initdb 仅需执行一次
启动PostgreSQLsystemctl start postgresql-11

设置自启动systemctl enable postgresql-11

查看运行状态systemctl status postgresql-11

开机启动chkconfig postgresql-11 on

重置密码1) sudo -u postgres psql2) ALTER USER postgres WITH PASSWORD ‘postgres’;3) 退出 \q

开启远程访问vi /var/lib/pgsql/11/data/postgresql.conf修改#listen_addresses = ‘localhost’ 为 listen_addresses=’*’,建议只监听内网IP
修改客户端认证配置文件pg_hba.confvi /var/lib/pgsql/11/data/pg_hba.conf将IPv4区下的127.0.0.1/32修改为0.0.0.0/0; 将ident修改为md5
重启服务service postgresql-11 restart

开放端口firewall-cmd –zone=public –add-port=5432/tcp –permanent

重载防火墙firewall-cmd –reload

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理