操作系统: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. 网易游戏2015年暑期实习生面试经历-游戏研发project师

    首先,我还是先介绍一下网易游戏吧.引用别人的一段话 作者:王选易.出处: http://www.cnblogs.com/neverdie/ 欢迎转载 .也请保留这段声明.假设你喜欢这篇文章,请点[推荐 ...

  2. 管理Mysql常用指令

    知识会更新,数据库系统也一样,本文只保证对Mysql 5.7以及MariaDB 10有效. 编码篇 展示当前默认的编码和字符集 SHOW VARIABLES LIKE 'char%'; 修改服务器默认 ...

  3. App.config和Web.config配置文件的配置节点的解析

    前言 在http://www.cnblogs.com/aehyok/p/3558661.html这篇博文中,大致对配置文件有了初步的了解,并且在文中有提到过<appSettings>和&l ...

  4. ios之调用打电话,发短信,打开网址

    1.调用 自带mail [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://admin@hz ...

  5. RecyclerView常见问题解决方案,RecyclerView嵌套自动滚动,RecyclerView 高度设置wrap_content 无作用等问题

    1,ScrollView或者RecyclerView1 嵌套RecyclerView2  进入页面自动跳转到recyclerView2上面页面会自动滚动貌似是RecyclerView 自动获得了焦点两 ...

  6. 洛谷 P1347 排序

    题目描述 一个不同的值的升序排序数列指的是一个从左到右元素依次增大的序列,例如,一个有序的数列A,B,C,D 表示A<B,B<C,C<D.在这道题中,我们将给你一系列形如A<B ...

  7. 里诺全系列注册机+暗桩patch

    一直有坛友私信更新里诺,今天花了一天时间,将里诺全系列更新完毕,权当送给坛友们的新年礼物吧! 全系列开放至元旦假期结束,后面就随机开放了. <ignore_js_op> 使用说明: 1.选 ...

  8. Ubuntu sh命令无法正确执行 (修改默认sh为bash)

    新安装的ubuntu,执行shell命令,都怀疑自己的shell水平了. 原来, ubuntu默认的是dash, 需要手动执行命令将dash改为bash. 命令: sudo dpkg-reconfig ...

  9. Linux下的串口编程实例

    //串口相关的头文件  #include<stdio.h>      /*标准输入输出定义*/  #include<stdlib.h>     /*标准函数库定义*/  #in ...

  10. FastReport.Net 入门

    任何一门编程技术入门体验都是以“Hello World”开始的,但我想再复杂一点的“Hello World”,才能算真正的入门.   FastReport.Net V1.2.76 ,vs2008 在 ...