PostgreSQL
1 使用docker来进行安装
1.1 拉取相关的镜像文件
docker pull postgres:11
1.2 运行
docker run --name pg -p 5432:5432 -e POSTGRES_PASSWORD=123456 -d postgres:11
2 在centos7下安装
2.1 前往官网查看需要的版本
2.2 使用的安装命令
#下载
yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum -y install postgresql11
yum -y install postgresql11-server
2.3 开启对应端口
#开启防火墙对应端口
firewall-cmd --permanent --add-port=5432/tcp
firewall-cmd --reload
2.4 初始化数据库
/usr/pgsql-11/bin/postgresql-11-setup initdb
systemctl enable postgresql-11
systemctl start postgresql-11
2.5 修改配置
#修改对应的配置
vim /var/lib/pgsql/11/data/postgresql.conf
修改监听所有的计算机对本服务器的连接,其中*
表示监听所有
修改都服务器的连接
vim /var/lib/pgsql/11/data/pg_hba.conf
host all all 0.0.0.0/0 trust 表示所有计算机都可以连接服务器
host all all 192.168.0.1/32 表示这个192.168.0.1
网段内的计算机都可以连接服务器
host all all 192.168.0.183 表示只有一个端口可以访问服务器
2.6重启数据库
systemctl restart postgresql-11