zoukankan      html  css  js  c++  java
  • postgresql 11.6 源码安装

    1.下载源码介质
    下载地址:
    源码下载地址: https://www.postgresql.org/ftp/source/
    二进制下载地址:https://www.enterprisedb.com/download-postgresql-binaries

    2.安装依赖包
    yum install readline
    yum install gcc
    yum -y install -y readline-devel
    yum install zlib-devel


    3.二进制安装
    [root@localhost soft]#mkdir -p /opt/postgresql-11.6
    [root@localhost soft]#./configure --prefix=/opt/postgresql-11.6
    [root@localhost soft]#make
    [root@localhost soft]#make install

    4.创建相应的用户
    [root@localhost opt]# groupadd postgres
    [root@localhost opt]# useradd -g postgres postgres


    5.创建数据及日志目录,并做相应授权
    [root@localhost soft]#mkdir -p /opt/postgresql-11.6/{data,log}
    [root@localhost soft]#chown -R postgres:postgres /opt/postgresql-11.6


    6.初始化数据库
    #su - postgres
    [postgres@localhost bin]$ cd /opt/postgresql-11.6/bin
    [postgres@localhost bin]$ ./initdb -D /opt/postgresql-11.6/data/

    7.启动数据库
    [postgres@localhost bin]$ cd /opt/postgresql-11.6/bin
    [postgres@localhost bin]$./pg_ctl -D /opt/postgresql-11.6/data -l /opt/postgresql-11.6/log/postgres.log start


    8.登陆使用
    [postgres@localhost bin]$cd /opt/postgresql-11.6/bin
    [postgres@localhost bin]$ ./psql
    psql (11.6)
    Type "help" for help.

    postgres=# du
                                       List of roles
     Role name |                         Attributes                         | Member of
    -----------+------------------------------------------------------------+-----------
     postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
     
    9.设置环境变量
    [postgres@localhost ~]$ vi .bash_profile
    # .bash_profile

    # Get the aliases and functions
    if [ -f ~/.bashrc ]; then
            . ~/.bashrc
    fi

    # User specific environment and startup programs

    PATH=$PATH:$HOME/.local/bin:$HOME/bin:/opt/postgresql-11.6/bin

    export PATH

    10.修改postgres用户的访问密码并测试建库建表
    PostgreSQL 数据库默认会创建一个postgres的数据库用户作为数据库的管理员,默认密码为空,我们需要修改为指定的密码,这里设定为postgres.
    su - postgres
    psql
    # ALTER USER postgres WITH PASSWORD 'postgres';
    # select * from pg_shadow ;
    # create database hxl;
    # c hxl

    project=# create table person(id integer, name text);
    project=# insert into person values (1, 'hxl');
    project=# select * from person;

    11.配置postgresql允许远程访问
    只需要修改data目录下的pg_hba.conf和postgresql.conf这两个文件:
    pg_hba.conf:配置对数据库的访问权限;
    postgresql.conf:配置PostgreSQL数据库服务器的相应的参数

    vim /opt/postgresql-11.6/data/pg_hba.conf

    # IPv4 local connections:
    host    all             all             127.0.0.1/32            trust
    host    all             all             0.0.0.0/0               md5


    重新加载配置文件
    su - postgres
    pg_ctl -D /opt/postgresql-11.6/data reload


    修改postgresql.conf
    vim /opt/postgresql-11.6/data/postgresql.conf

    listen_addresses = '*'   # what IP address(es) to listen on;
    修改该改参数需要重启动

    pg_ctl -D /opt/postgresql-11.6/data -l /opt/postgresql-11.6/log/postgres.log stop
    pg_ctl -D /opt/postgresql-11.6/data -l /opt/postgresql-11.6/log/postgres.log start

    12.修改postgres用户的密码

    [postgres@localhost log]$ psql
    postgres=# alter user postgres with password 'postgres';

    然后通过navicate for postgresql即可进行连接

  • 相关阅读:
    缓存之雪崩现象与穿透现象
    Linux下安装php的memcached扩展(memcache的客户端)
    Linux下编译、安装php
    Linux下编译、安装并启动apache
    Linux下编译、安装并启动memcached
    memcached内存分配机制
    Memcached的过期数据的过期机制及删除机制(LRU)
    linux下mysql的root密码忘记----解决方案
    Linux服务管理
    Python中import机制
  • 原文地址:https://www.cnblogs.com/hxlasky/p/12187660.html
Copyright © 2011-2022 走看看