postgresql linux rpm,CentOS7下使用RPM安装PostgreSQL10

66b52468c121889b900d4956032f1009.png

8种机械键盘轴体对比

本人程序员,要买一个写代码的键盘,请问红轴和茶轴怎么选?

安装依赖1yum -y install libicu libxslt-devel

准备RPM包1

2

3

4postgresql10-10.4-1PGDG.rhel7.x86_64.rpm

postgresql10-contrib-10.4-1PGDG.rhel7.x86_64.rpm

postgresql10-libs-10.4-1PGDG.rhel7.x86_64.rpm

postgresql10-server-10.4-1PGDG.rhel7.x86_64.rpm

安装1rpm -ivh *.rpm

初始化数据库

默认数据目录: /var/lib/pgsql/10/data/1/usr/pgsql-10/bin/postgresql-10-setup initdb

自定义目录1

2

3

4

5mkdir -p /opt/PostgreSQL/data

chmod 755 -R /opt/PostgreSQL/data

chown postgres:postgres -R /opt/PostgreSQL

su postgres

/usr/pgsql-10/bin/initdb --encoding=UTF-8 --local=zh_CN.UTF8 --username=postgres --pwprompt --pgdata=/opt/PostgreSQL/data

修改service环境变量

修改Environment:PGDATA的数据目录为/opt/PostgreSQL/data1

2vim /usr/lib/systemd/system/postgresql-10.service

systemctl daemon-reload

修改postgres用户的环境变量PGDATA1

2su postgres

vi ~/.bash_profile

启动1

2

3

4

5

6# 启动

systemctl start postgresql-10.service

# 开机启动

systemctl enable postgresql-10.service

# 关闭开机启动

systemctl disable postgresql-10.service

登录1

2su postgres

psql -U postgres

查看当前数据目录1

2

3

4show data_directory;

----------------------

/opt/PostgreSQL/data

(1 row)

修改密码1

2postgres=# password

ALTER USER postgres WITH PASSWORD 'xxxxx';

数据库登录权限设置

$PGDATA/pg_hba.conf 权限相关配置1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16# TYPE DATABASE USER ADDRESS METHOD

# "local" is for Unix domain socket connections only

local all all md5

# IPv4 local connections:

#host all all 127.0.0.1/32 trust

host all all 0.0.0.0/0 md5

# IPv6 local connections:

#host all all ::1/128 trust

host all all ::0/0 md5

# Allow replication connections from localhost, by a user with the

# replication privilege.

#local replication all trust

#host replication all 127.0.0.1/32 trust

#host replication all ::1/128 trust

host replication repl slave trust

设置trust,本地可以使用psql -U postgres直接登录服务器

设置peer,本地可以使用psql -h 127.0.0.1 -d postgres -U postgres直接登录服务器

设置password,使用用户名密码登录

$PGDATA/postgresql.conf 数据库相关配置1

2listen_addresses = '*'

posrt = 5432

设置监听任意IP, 允许任意ip连接数据库

更多权限说明,见官方文档

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值