操作系统: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. C#编程(四十六)----------正则表达式

    正则表达式 1.定义一个Regex类的实例 Regex regex=new Regex(“”); 这里初始化参数就是一个正则表达式,”\d”表示配置数字 2.判断是否匹配 判断一个字符串,是否匹配一个 ...

  2. SharePoint 2013 workflows stop working (Failed on started.)

    前言 最近,使用工作流的时候碰到了一个问题,突然间所有工作流都无法启动,报错Failed on started. 同时,工作流内部报错,工作流被系统账号取消了. 查了很久,发现系统打了windows ...

  3. PlaceholderTextView

    PlaceholderTextView 效果 源码 https://github.com/YouXianMing/UI-Component-Collection 的 PlaceholderTextVi ...

  4. linux设置允许和禁止访问的IP host.allow 和 host.deny

    对于能过xinetd程序启动的网络服务,比如ftp telnet,我们就可以修改/etc/hosts.allow和/etc/hosts.deny的配制,来许可或者拒绝哪些IP.主机.用户可以访问. 比 ...

  5. 进一步优化ListView

    之前我已经分享过一篇:viewHodler的通用写法,就是专门用来优化listview的加载的,但是对于复杂的布局,我们还需要在listview滑动和不滑动时进行自己的处理,今天我看到一篇文章就是讲这 ...

  6. 《Java性能优化权威指南》

    <Java性能优化权威指南> 基本信息 原书名:Java performance 原出版社: Addison-Wesley Professional 作者: (美)Charlie Hunt ...

  7. jQuery easyui layout布局自适应浏览器大小(转)

    首先解释一下标题的含义,当我们用jQuery easyui layout 进行布局的时候,可能会遇到这样一个问题,那就是当手工调整浏览器大小,或者最大化.还原窗口的时候,layout的某个区域不能填充 ...

  8. Context Application 使用总结 MD

    Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...

  9. C#线程同步方法汇总

    我们在编程的时候,有时会使用多线程来解决问题,比如你的程序需要在 后台处理一大堆数据,但还要使用户界面处于可操作状态:或者你的程序需要访问一些外部资源如数据库或网络文件等.这些情况你都可以创建一个子线 ...

  10. java.sql.SQLException: ORA-01461: 仅能绑定要插入 LONG 列的 LONG 值

    问题来源:我在执行sql生成json并存入数据库是报的错. 原因:存json的字段我定义其类型为varchar2. 分析:这个异常是指,用户向数据库执行插入数据操作时,某条数据的某个字段值过长,如果是 ...