1. 官网上下载linux的Pg12.2:http://www.postgres.cn/v2/download并解压
2. cd potgresql-12.2
3. ./configure --prefix=/opt/pgsql #拟安装至/opt/pgsql
执行前先安装gcc,readline,readline-devel,zlib,zlib-devel
用yum -y install -y readline,如果直接yum install下完了还会报错:
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.
修改权限chmod -R 777 ./configure再执行
成功:
4. make world
执行前先安装libxslt,还要安装依赖yum install xsltproc docbook-xsl docbook-xml
如果yum install epel-release后使用yum异常,修改repo文件后记得reboot即可,但这里不需要epel-release,直接安装libxslt,没安装libxslt会报错:
xsltproc is missing on your system.
没安装依赖会报错:
/usr/bin/xsltproc --path . --stringparam pg.version '12.2' stylesheet.xsl postgres.sgml
error : No such file or directory
warning: failed to load external entity
http://docbook.sourceforge.net/release/xsl/current/xhtml/param.xsl"
compilation error: file http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook-no-doctype.xsl line 21 element include
xsl:include : unable to load http://docbook.sourceforge.net/release/xsl/current/xhtml/param.xsl
error : No such file or directory
warning: failed to load external entity "http://docbook.sourceforge.net/release/xsl/current/common/labels.xsl"
compilation error: file http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook-no-doctype.xsl line 26 element include
xsl:include : unable to load http://docbook.sourceforge.net/release/xsl/current/common/labels.xsl
成功:
5. make install-world
十分的顺利啊哈哈哈哈哈哈哈哈
6. adduser postgres #增加新用户;
mkdir /opt/pgsql/data #创建数据库目录;
chown -R postgres:postgres /opt/pgsql/datasu - postgres #使用postgres帐号操作
7. /opt/pgsql/bin/initdb -D /opt/pgsql/data #初始化数据库
8. /opt/pgsql/bin/pg_ctl -D /opt/pgsql/data -l logfile start #启动数据库
/opt/pgsql/bin/createdb genericdb #假定数据库名为gerericdb)
/opt/pgsql/bin/psql genericdb # (进入数据库内部)