postgresql安装使用

centos自带的postgresql

yum install postgresql
yum install postgresql-server
安装完成以后:可以搜索查找位置
which psql
which postgresql-setup
whereis postgresql-setup

安装完成会自动生成postgres用户,初始时,只能在该用户下使用,使用之前先初始化
postgresql-setup initdb

进入数据库目录:
/var/bin/psql
修改配置文件:/var/bin/psql/data/pg_hba.conf

local all all peer
修改为:
local all all trust
host all all 0.0.0.0/0 md5(远程)

远程连接:/var/bin/psql/data/postgresql.conf
去掉注释:修改listen_addresses属性为"*"
数据库启动 service postgresql start

然后第一次登陆:su - postgres
psql -u postgres
修改密码:\password
或者:alter user postgres with password ‘123456’
推出
\q
exit

centos 高版本安装

[root@localhost ~]# yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
[root@localhost ~]# yum install -y postgresql11
[root@localhost ~]# yum install -y postgresql11-server
初始化[root@localhost ~]# /usr/pgsql-11/bin/postgresql-11-setup initdb
效果:
Initializing database … OK

设置外连接,修改端口:
[root@localhost ~]# vim /var/lib/pgsql/11/data/postgresql.conf
在这里插入图片描述
vim /var/lib/pgsql/11/data/pg_hba.conf
修改为在这里插入图片描述
systemctl start postgresql-11

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

研程序笔记

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值