栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

postgresql 安装部署及运行

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

postgresql 安装部署及运行

1.postgresql官网地址 https://www.postgresql.org/

2.下载地址   https://www.postgresql.org/download/linux/redhat/

选择对应的操作系统及安装版本,下面以9.6为例 

# Install the repository RPM:
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

# Install PostgreSQL:
sudo yum install -y postgresql96-server

# Optionally initialize the database and enable automatic start:
sudo /usr/pgsql-9.6/bin/postgresql96-setup initdb
sudo systemctl enable postgresql-9.6
sudo systemctl start postgresql-9.6

到这里安装及启动完成

3.修改配置文件,改为md5 密码登录
 

vi /var/lib/pgsql/9.6/data/pg_hba.conf

#host    all             all             127.0.0.1/32            ident
host    all             all             127.0.0.1/32            md5

4.配置用户及数据库

passwd postgres

su - postgres

createuser testpost

# 登录数据库
psql

# 创建数据库testpost
CREATE DATAbase testpost WITH ENCODING 'UTF8' OWNER testpost TEMPLATE=template0;

#设置testpost用户密码
alter user testpost with password 'testpost';

#给testpost授权           
alter role testpost createdb;
alter role testpost superuser;
alter role testpost createrole;  

#更改test数据库拥有者
alter database testpost owner to testpost;

#进入命令行
psql

#指定用户
psql -U testdb -h 127.0.0.1

#查看库情况   
l   

#查看用户      
du    
  
# 退出
q

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/450283.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号