Linux安装postgresql
官网下载压缩包,地址:下载
- 将下载好的压缩包放至服务器,解压
tar -zxvf postgresql
- 进入解压后的文件夹
cd postgresql
- 运行configure
./configure
如果这一步报了这个错,说明系统已经安装了readline包
configure: error: readline library not found
If you have readline already installed, see config.log for details on the
failure. It is possible the compiler isn’t looking in the proper directory.
Use --without-readline to disable readline support.
可以运行一下这个命令,看看是不是这个包的问题
yum -y install -y readline-devel
重新 ./configure
又出现了一个类似的错误
configure: error: zlib library not found
If you have zlib already installed, see config.log for details on the
failure. It is possible the compiler isn’t looking in the proper directory.
Use --without-zlib to disable zlib support.
运行下面的命令
yum install zlib-devel
再来一次 ./configure
成功。
make
make install
- 配置环境变量
#配置环境变量前先创建一个文件夹
mkdir /usr/local/pgsql/data
vim ~/.bash_profile
#写入以下配置
export PGHOME=/usr/local/pgsql
export PGDATA=/usr/local/pgsql/data
- 保存退出后执行命令,使配置生效
source ~/.bash_profile
- 创建一个普通用户
- 然后依次执行以下命令
chown postgres /usr/local/pgsql/data
su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &
cd usr/local/pgsql/bin
./pg_ctl start
#如果需要修改端口号,在安装目录的bin文件夹内,
vim postgresql.conf
上一篇: pip更换国内的安装源 / 镜像
下一篇: Linux下Mysql安装