加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

postgresql9.5 安装使用

发布时间:2020-12-13 16:40:01 所属栏目:百科 来源:网络整理
导读:postgresql9.5 安装使用 1 下载安装postgresql9.5 1.1 官网下载 https://www.postgresql.org/download/linux/redhat/ 1.2 下载postgresql9.5的repo # yum install https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/pgdg-redhat95-9.

postgresql9.5 安装使用

1 下载&安装postgresql9.5

1.1 官网下载

https://www.postgresql.org/download/linux/redhat/

1.2 下载postgresql9.5的repo

# yum install https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/pgdg-redhat95-9.5-3.noarch.rpm


# ll /etc/yum.repos.d/

-rw-r--r-- 1 root root 482 Jan 5 2016 pgdg-95-redhat.repo


1.3 安装postgresql9.5的客户端

# yum install postgresql95


1.4安装postgresql9.5的服务端

# yum install postgresql95-server


1.5 设置数据库开机自起

# systemctl enable postgresql-9.5

# systemctl start postgresql-9.5


1.6 查看数据运行的状态

# systemctl status postgresql-9.5.service
● postgresql-9.5.service - PostgreSQL 9.5 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-9.5.service; enabled; vendor preset: disabled)

Active: active (running) since Wed 2018-04-18 07:40:03 EDT; 52s ago

*****************


1.7 初始化postgresql9.5数据库

# /usr/pgsql-9.5/bin/postgresql95-setup initdb
Initializing database ... OK


2 配置 & 使用postgresql9.5数据库

参考:https://help.ubuntu.com/stable/serverguide/postgresql.html

2.1 修改postgres用户的密码

# su - postgres

-bash-4.2$ psql -U postgres

postgres=# ? -- 查看帮助

postgres=# ALTER USER postgres WITH PASSWORD '1234' --修改postgres用户的密码

postgres-# q --退出修改


2.2开启远程访问数据库

# vi /var/lib/pgsql/9.5/data/postgresql.conf

******

listen_addresses = '*' # what IP address(es) to listen on;


2.3信任远程连接

修改成以下配置

# vi /var/lib/pgsql/9.5/data/pg_hba.conf

***********

# IPv4 local connections:
host all all 127.0.0.1/32 md5

host all all ::/32 md5


local replication postgres md5


2.4 关闭linux服务器的防火墙

#systemctlstopfirewalld

#systemctldisablefirewalld


2.5 重启postgresql服务

# systemctl restart postgresql-9.5.service

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读