zoukankan      html  css  js  c++  java
  • centos7安装postgresql和postgis

    1、安装步骤

    -- 安装对应的rpm文件(其他系统的rpm包,请自行到https://yum.postgresql.org/下载)
    yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

    -- 查询postgresql的版本

    yum search postgresql
    -- 安装对应的版本(我安装的是postgresql9.6+postgis2.4)
    yum -y install postgresql96.x86_64 postgresql96-server.x86_64 postgresql96-devel.x86_64
    -- 安装对应的postgis插件
    yum install postgis24_96.x86_64
    如果出现如下图所示错误,

    请执行如下命令:rpm -ivh http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

    执行完毕后,继续执行yum install postgis24_96.x86_64

    至此整个安装过程完毕!

      2、初始化运行环境

    -- 初始化数据库
    /usr/pgsql-9.6/bin/postgresql96-setup initdb
    -- 启动psql服务器
    systemctl start postgresql-9.6
    --设置开机自启动
    systemctl enable postgresql-9.6
    --开发防火墙
    firewall-cmd--permanent --add-port=5432/tcp
    firewall-cmd--reload
    -- 修改pg_hba.conf和postgresql.conf
    /var/lib/pgsql/9.6/data/pg_hba.conf 将配置文件中记录的method的ident修改为trust(可以实现用户名和密码访问数据库)
    /var/lib/pgsql/9.6/data/postgresql.conf 修改listen_addresses = 'localhost'为listen_addresses= '*',允许所有远程访问
    (这样可以在其它客户机上远程登陆服务器,比如在windows机器上使用pgadmin客户端)

    -- 初始化数据库

    su postgresql

    --登录到数据库

    psql(可以默认登陆到用户名为:postgres 数据库名为postgres的数据库)

    --查看当前连接到的数据库

    c

    --查看当前的数据库信息

    l

    --查看当前数据库的表信息

    d

    --导入sql脚本

    第一种方法:i  sql脚本的路径信息 

    第二种:psql -U 用户 -d 数据库 -h 主机 -p 端口 -f 脚本路径

    至此基本的安装,初始化过程就结束了,  如果你在过程中有任何疑问,欢迎交流学习!

  • 相关阅读:
    关于tomcat启动时报错Address already in use: JVM_Bind
    matlab学习笔记第四章——统计和MATLAB编程介绍
    matlab学习笔记第三章——绘图与图形
    matlab学习笔记第二章——矩阵
    matlab学习笔记第一章
    机器学习 什么是监督学习和无监督学习
    matlab M文件和面向对象编程
    matlab 字符串、元胞和构架数组
    使用VMware搭建3台一模一样的Linux虚拟机 搭建hadoop集群环境
    Hadoop之单机模式环境搭建
  • 原文地址:https://www.cnblogs.com/ljy-20180122/p/12371929.html
Copyright © 2011-2022 走看看