加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

PostgreSQL安装

发布时间:2020-12-13 18:08:19 所属栏目:百科 来源:网络整理
导读:#下载 访问https://www.postgresql.org/download/, 点击左侧的‘source' 进行下载,一般选择bz2的安装包。 #安装相关软件包 yum install -y zlib-devel yum install -y readline-devel #安装PostgreSQL tar -xvf postgresql-9.5.6.tar.bz2 cd postgresql-9.

#下载

访问https://www.postgresql.org/download/,点击左侧的‘source'进行下载,一般选择bz2的安装包。

#安装相关软件包

yum install -y zlib-devel

yum install -y readline-devel

#安装PostgreSQL

tar -xvf postgresql-9.5.6.tar.bz2

cd postgresql-9.5.6

./configure --prefix=/usr/local/pgsql9.5.6--enable-thread-safety --with-perl --with-python

make

make install

ln -s /usr/local/pgsql9.5.6 /usr/local/pgsql

#安装contrib下的工具

cd postgresql-9.5.6/contrib

make

make install

export PATH=$PATH:/usr/local/pgsql/bin

export LD_LIBRARY_PATH=/usr/local/pgsql/lib

#让以上设置对所有用户生效

vi /etc/profile

在最后添加:

export PATH=$PATH:/usr/local/pgsql/bin

exportLD_LIBRARY_PATH=/usr/local/pgsql/lib:$LD_LIBRARY_PATH

cd /data/server

mkdir pgdata

export PGDATA=/data/server/pgdata

[root@pc2 server]# initdb

initdb: cannot be run as root

Please log in (using,e.g.,"su")as the (unprivileged) user that will

own the server process.

#新建普通用户,初始化数据库

useradd postgres

cd /data/server

chown -R postgres:postgres pgdata

su - postgres

export PGDATA=/data/server/pgdata

initdb

#启动数据库

pg_ctl -D /data/server/pgdata start

#登录数据库测试

[postgres@pc2 ~]$ psql

psql (9.5.6)

Type "help" for help.

postgres-# l

List ofdatabases

Name | Owner| Encoding | Collate |Ctype | Access privileges

-----------+----------+----------+-------------+-------------+-----------------------

postgres| postgres | UTF8 |en_US.UTF-8 | en_US.UTF-8 |

template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |=c/postgres +

| || | | postgres=CTc/postgres

template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |=c/postgres +

| | | | | postgres=CTc/postgres

(3 rows)

--本篇文章参考自《PostgreSQL 修炼之道:从小工到专家》

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读