1.PostgreSQL下载安装
发布日期:2021-11-08 09:37:46 浏览次数:1 分类:技术文章

本文共 2865 字,大约阅读时间需要 9 分钟。

下载地址:https://www.postgresql.org/ftp/source/v10.1/
想看详细介绍请看官方文档 : http://www.postgres.cn/docs/9.5/install-procedure.html
1. 安装:
[root@mysqltest1 postgresql-10.1]# ./configure --prefix=/usr/local/pgsql
......
configure: error: in `/usr/local/postgresql-10.1':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
缺少 gcc包, 安装gcc包
[root@mysqltest1 postgresql-10.1]# yum -y install gcc
configure: error: readline library not found</span>
据提示,应该是没有安装 readline包。
3 检查系统是否安装 readline 包
[root@mysqltest1 postgresql-10.1]# rpm -qa | grep readline
readline-6.2-10.el7.x86_64</span>
4 通过 yum 搜索相关的readline 包
[root@mysqltest1 postgresql-10.1]# yum search readline
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: mirrors.tuna.tsinghua.edu.cn
================================================================ N/S matched: readline ================================================================
readline-devel.i686 : Files needed to develop programs which use the readline library
readline-devel.x86_64 : Files needed to develop programs which use the readline library
readline-static.i686 : Static libraries for the readline library
readline-static.x86_64 : Static libraries for the readline library
perl-Term-UI.noarch : Term::ReadLine user interface made easy
readline.i686 : A library for editing typed command lines
readline.x86_64 : A library for editing typed command lines
5. 安装 readline-devel 包
[root@mysqltest1 postgresql-10.1]# yum -y install -y readline-devel
6.编译安装
make 编译
make install 安装
7.配置共享库:
LD_LIBRARY_PATH=/usr/local/pgsql/lib
export LD_LIBRARY_PATH</span>
8. 环境变量
[root@mysqltest1 pgsql]# su - pgsql
[root@mysqltest1 pgsql]# vim .bash_profile
export PGHOME=/usr/local/pgsql  
export PGDATA=/usr/local/pgsql/data  
export PGLIB=/usr/local/pgsql/lib  
export PATH=$PGHOME/bin:$PATH  
source /home/pgsql/.bash_profile
9.查看环境变量是否生效
[root@mysqltest1 /]# psql -V
psql (PostgreSQL) 10.1
9. 创建用户,跟oracle一样,pgsql需要单独创建一个用户进行管理
useradd pgsql
chown pgsql:pgsql /usr/local/pgsql -R 
10. 初始化数据库
由于配置了环境变量,所以此处我们直接执行initdb即可完成db初始化,但在这之前可以通过initdb --help看一下初始化相关的帮助信息: 
初始化
initdb -D /usr/local/pgsql/data/  
启动服务
pg_ctl -D /usr/local/pgsql/data/ -l /usr/local/pgsql/logs/logfile start 
11.启动失败,log文件报错信息:
could not open lock file "/tmp/.s.PGSQL.5432.lock": 权限不够
解决办法:
chown pgsql:pgsql /tmp/.s.PGSQL.5432.lock
12.创建数据库
[pgsql@mysqltest1 data]$ createdb mydb
[pgsql@mysqltest1 data]$ dropdb mydb
13. 访问数据库:
[pgsql@mysqltest1 data]$ psql mydb
psql (10.1)
Type "help" for help.
mydb=# 
14. 查看版本
mydb=# select version();'
                                              version                                                
---------------------------------------------------------------------------------------------------------
PostgreSQL 10.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16), 64-bit
(1 row)

转载地址:https://blog.csdn.net/zhengwei125/article/details/79220757 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:InnoDB: ./ib_logfile0 can't be opened in read-write mode.
下一篇:2.PostgreSQL创建用户和远程访问

发表评论

最新留言

网站不错 人气很旺了 加油
[***.192.178.218]2024年03月23日 13时42分10秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章