操作系统:CentOS7
安装文件:postgresql-10.0.tar.gz

系统环境:gcc、Python

1:源码安装

[postgres@localhost ~]# tar zxvf postgresql-10.0.tar.gz
[postgres@localhost ~]# mv postgresql-10.0 /usr/local/pgsql/
[postgres@localhost ~]# cd /usr/local/pgsql/
[root@localhost pgsql]# ./configure --prefix=/usr/local/pgsql --without-readline --without-zlib
[root@localhost pgsql]# make
[root@localhost pgsql]# make install

2:添加postgres用户,设置目录权限

[root@localhost ~]# adduser postgres
[root@localhost ~]# passwd postgres
[root@localhost ~]# mkdir -p /usr/local/pgsql/data
[root@localhost ~]# chown -R posgres:root /usr/local/pgsql/
[root@localhost ~]# chown -R postgres:root /usr/local/pgsql/

3:设置环境变量

[root@localhost ~]# su - postgres
[postgres@localhost ~]$ vim ~/.bash_profile
PATH=$PATH:/usr/local/pgsql/bin
[postgres@localhost ~]$ source ~/.bash_profile

4:添加启动服务

()添加启动服务
[root@localhost ~]# cp /usr/local/pgsql/contrib/start-scripts/linux /etc/init.d/postgresql
[root@localhost ~]# chmod u+x /etc/init.d/postgresql
()添加开机自启动
[root@localhost ~]# chkconfig --add postgresql
()启动服务
[root@localhost ~]# service postgresql start
Starting PostgreSQL: ok

5:切换到postgres用户,初始化数据库

[postgres@localhost data]$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process. The database cluster will be initialized with locale "zh_CN.UTF-8".
The default database encoding has accordingly been set to "UTF8".
initdb: could not find suitable text search configuration for locale "zh_CN.UTF-8"
The default text search configuration will be set to "simple". Data page checksums are disabled. fixing permissions on existing directory /usr/local/pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ...
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb. Success. You can now start the database server using: /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start

6:修改postgresql配置

()允许所有连接
[postgres@localhost ~]$ vi /usr/local/pgsql/data/pg_hba.conf
# IPv4 local connections:
host all all 0.0.0.0/ trust
()侦听所有连接
[postgres@localhost ~]$ vi /usr/local/pgsql/data/postgresql.conf
listen_addresses = '*'
logging_collector = on

7:启动数据库

[postgres@localhost data]$  /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start
waiting for server to start.... done
server started

8:设置postgres用户的密码

[postgres@localhost ~]$ psql
psql (10.0)
Type "help" for help. postgres=# \password
Enter new password:
Enter it again:

9:查看当前数据库列表

10:创建角色、数据库,切换数据库、用户

postgres=# create role test login password 'test';
CREATE ROLE
postgres=# create database testdb with owner=test;
CREATE DATABASE
postgres=# \c testdb;
You are now connected to database "testdb" as user "postgres".
testdb=# \c - test;
You are now connected to database "testdb" as user "test".
testdb=>

11:本地通过pgAdmin4进行连接

在CentOS7(虚拟机)下通过源码安装Postgresql10以及基本配置的更多相关文章

  1. Centos7 linux下通过源码安装redis以及使用

    下载redis安装包 wget http://download.redis.io/releases/redis-5.0.3.tar.gz 解压压缩包 tar -zxvf redis-.tar.gz y ...

  2. linux下通过源码安装git

    1.移除旧版本git [root@Git ~]# git --version ## 查看自带的版本git version 1.8.3.1 [root@Git ~]# yum remove git ## ...

  3. Linux下通过源码编译安装程序

    本文简单的记录了下,在linux下如何通过源码安装程序,以及相关的知识.(大神勿喷^_^) 一.程序的组成部分 Linux下程序大都是由以下几部分组成: 二进制文件:也就是可以运行的程序文件 库文件: ...

  4. 通过源码安装PostgresSQL

    通过源码安装PostgresSQL 1.1 下载源码包环境: Centos6.8 64位 yum -y install bison flex readline-devel zlib-devel yum ...

  5. 在centos6.7通过源码安装python3.6.7报错“zipimport.ZipImportError: can't decompress data; zlib not available”

    在centos6.7通过源码安装python3.6.7报错: zipimport.ZipImportError: can't decompress data; zlib not available 从 ...

  6. Ubuntu 14.04 卸载通过源码安装的库

    cd cere-solvermkdir buildcd buildcmake ..sudo makesudo make install 卸载通过以上方式源码安装的库 再次进入buildsudo mak ...

  7. 【Git】CentOS7 通过源码安装Git

    yum源仓库里的Git版本更新不及时,最新版的Git是1.8.3,但是官方的最新版早已经更新到2.9.5.想要安装最新版本Git,只能下载源码进行安装 建议最好更新git为较新版本,便于使用 1.查看 ...

  8. Linux下通过源码编译安装程序(configure/make/make install的作用,然后在/etc/profile文件里修改PATH环境变量)

    一.程序的组成部分 Linux下程序大都是由以下几部分组成: 二进制文件:也就是可以运行的程序文件 库文件:就是通常我们见到的lib目录下的文件 配置文件:这个不必多说,都知道 帮助文档:通常是我们在 ...

  9. CentOS7通过源码安装nginx

    需要先安装安装环境和库: yum install gcc-c++ yum install -y pcre pcre-devel yum install -y zlib zlib-devel yum i ...

随机推荐

  1. Odoo进销存(采购、销售、仓库)入门教程 - 上

    转载地址:http://blog.csdn.net/wangnan537/article/details/46434373 运行环境: Ubuntu14.04+Odoo8.0 作者:苏州-微尘 0. ...

  2. 【gitlab】首次提交本次代码到gitlab上,报错:Updates were rejected because the remote contains work that you do

    首次提交本次代码到gitlab上,报错:Updates were rejected because the remote contains work that you do 报错情况如下: 错误原因: ...

  3. SqlServer 查看备份文件中逻辑文件信息的Sql语句

    RESTORE FILELISTONLY FROM DISK = 'D:\All\DataBase\(2013-12-18)-1.bak' 用来查看备份文件中的逻辑文件信息. 相关信息:SqlServ ...

  4. Ubuntu 16.04 grub rescue 模式下修复 grub

      前几天整理了下电脑的分区,合并并删除一些分区,结果导致 grub 被破坏了,Ubuntu进不去了,启动后直接进入了 rescure 模式.后来又折腾了下,终于修复好了,现总结一下. 先说一下我的系 ...

  5. python读取配置文件的方式

    python读取配置文件的方式 1.从config.ini中读取,后缀无所谓,文件名字也无所谓,不过config.ini是常用写法,所谓见名知意 config.ini内容: [global] ip = ...

  6. Zookeeper Tutorial 2 -- Programmer's Guide

    数据模型 ZooKeeper跟分布式文件系统一样, 有一系列的命名空间. 唯一不同的地方是命名空间中的每个节点都有数据和他相关联. 它类似于一个允许文件同时是一个目录的文件系统. 节点的路径永远是以斜 ...

  7. 硬盘杀手!Windows版Redis疯狂占用C盘空间!

    关键词:Redis占用C盘,Windows Redis,64位Windows版Redis疯狂占用C盘空间,redis启动后创建RedisQFolk_****.dat文件.redis-server.ex ...

  8. cocos2d-js中Chipmunk物理引擎相关(1)

    近期看些cocos2d-js的东西.用到当中的Chipmunk的一些东西.由于相关的资料也不是非常具体,所以看到一些东西实用就记录下来. 1. chipmunk是cocos2d的一个一个物理引擎.用来 ...

  9. 案例导入和导出Scott用户

    ylbtech-Oracle:案例导入和导出Scott用户  导入和导出Scott用户 1. 导出Scott用户下的所有对象返回顶部 1.1, Microsoft Windows [版本 ] 版权所有 ...

  10. 2014年.net程序员年终总结

    2014年经历了3家公司,感觉这一年工作不怎么顺利,在2013年1月进入一家外企从事软件架构设计.开发测试.部署实施的相关工作,在2013年感觉工作很充实,在2014年由于项目的原因被迫去做项目维护, ...