Centos 7 安装 Postgresql数据库

敲入以下命令

复制代码
# 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 postgresql14-server

# Optionally initialize the database and enable automatic start:
sudo /usr/pgsql-14/bin/postgresql-14-setup initdb
sudo systemctl enable postgresql-14
sudo systemctl start postgresql-14
复制代码

其他系统可以根据官网文档进行查阅

复制代码
# 切换postgres用户
sudo su - postgres
##开启远程访问
#修改配置文件  取消 listen_addresses 的注释,将参数值改为“*”
vi /var/lib/pgsql/14/data/postgresql.conf
#修改配置文件  增加一行 host   all   all   0.0.0.0/0   md5
vi /var/lib/pgsql/14/data/pg_hba.conf

#打开客户端,创建用户、数据库及用户授权
psql
create user test_zack with password '123456';
create database test_db owner test_zack;
grant all privileges on database test_db to test_zack;

#重启服务
sudo systemctl restart postgresql-14
复制代码

 

本文作者:風飄絮℃

本文链接:https://www.cnblogs.com/zacklau/p/16573287.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   風飄絮℃  阅读(277)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起