码迷,mamicode.com
首页 > 数据库 > 详细

CentOS7(64) yum安装、配置PostgreSQL 11

时间:2019-02-01 21:12:42      阅读:797      评论:0      收藏:0      [点我收藏+]

标签:lte   https   inux   blank   postgres   自启   登录   sql   参考   

一、安装postgresql11

1、Install the repository RPM: 添加RPM

yum install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm

2、Install the client packages: 安装PostgreSQL11

yum install postgresql11

3、Optionally install the server packages: 安装服务包  

yum install postgresql11-server

4、Optionally initialize the database and enable automatic start: 初始化数据库并使postgresql自启动

#初始化数据库
/usr/pgsql-11/bin/postgresql-11-setup initdb systemctl enable postgresql-11 systemctl start postgresql-11

5、View Version: 查看版本

psql --version

以上或在其它操作系统中安装其它版本可参考:https://www.postgresql.org/download/linux/redhat/  

二、配置postgresql11

1、修改用户密码并创建新库

[root@localhost ~]# su - postgres
-bash-4.2$ psql -U postgres

 【修改postgre的密码】

postgres=# ALTER USER postgres WITH PASSWORD ‘123456‘

 【创建数据库】

postgres=# CREATE DATABASE xxx OWNER postgres
成功后会提示:CREATE DATABASE

 【赋予用户postgres权限】

postgres=# GRANT ALL PRIVILEGES ON DATABASE xxx to postgres
成功提示:GRANT

 【退出】

postgres=# \q

 【直接登录】

-bash-4.2$ psql -U postgres -d xxx -h 127.0.0.1 -p 5432

2、开启远程访问

  vi /var/lib/pgsql/11/data/postgresql.conf
  修改#listen_addresses = ‘localhost‘  为  listen_addresses=‘*‘
  当然,此处‘*’也可以改为任何你想开放的服务器IP

3、信任远程连接
  vi /var/lib/pgsql/11/data/pg_hba.conf
  修改如下内容,信任指定服务器连接
  # IPv4 local connections:
  host    all            all      127.0.0.1/32      trust
  host    all            all      10.211.55.6/32(需要连接的服务器IP)  trust

  当然,此处也可以改为任意服务器IP,适用于访问者IP为动态可变

  host    all            all      0.0.0.0/0    trust

 4、重启postgresql

systemctl restart postgresql-11

  

CentOS7(64) yum安装、配置PostgreSQL 11

标签:lte   https   inux   blank   postgres   自启   登录   sql   参考   

原文地址:https://www.cnblogs.com/kevenwork/p/10346936.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!