前提:linux yum 详解https://blog.csdn.net/chengJiaGen/article/details/90647687
https://blog.csdn.net/xiaojin21cen/article/details/84726193
方式一: 源码安装
1、下载资源
https://ftp.postgresql.org/pub/source/v11.6/postgresql-11.6.tar.gz
2、将该文件上传至root文件夹下并解压
./configure 报错
image.png |
---|
解决办法 yum install gcc
安装完gcc 后,
-
./configure
image.png
configure时有警告,是因为CentOS6.4开始,已经不继续支持这两个函数库了,所以要加参数
- ./configure --without-readline --without-zlib
- gmake (编译)
- gmake install
adduser postgres
mkdir /usr/local/pgsql/data
chown postgres /usr/local/pgsql/data
su - postgres (切换到 postgres用户)
cd /usr/local/pgsql
./bin/initdb -D data
./bin/postgres -D data >./data/logffile 2>&1 & (启动数据库)
ps aux | grep postgres
./bin/createdb test 创建test数据库
./bin/psql test 进入数据库
参考文章:
https://www.cnblogs.com/liwangwang/p/12603167.html
方式二:yum安装
1、安装RPM
yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
2、安装客户端
yum install postgresql11
3、安装服务器端
yum install postgresql11-server
4、安装依赖包
yum install postgresql11-libs
yum install postgresql11-contrib
yum install postgresql11-devel
5、数据初始化与启动
/usr/pgsql-11/bin/postgresql-11-setup initdb
systemctl enable postgresql-11
systemctl start postgresql-11
6、修改密码
passwd postgres
登录psql
su - postgres
psql
配置外部访问
vim /var/lib/pgsql/11/data/postgresql.conf
启动服务
systemctl restart postgresql-11
网友评论