• 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 脚本路径

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

  • 相关阅读:
    HTML CSS3 手风琴菜单
    python代码- post请求图片上传
    python 一行代码生成 二维码
    Jenkins 中定时任务构建
    Jenkins 常用插件
    window系统,GitLab 远程与本地 SSH 认证连接
    Jmeter+Maven+Jenkins+Git接口自动化流程
    jmeter 响应中有中文乱码问题,解决
    Excel文件导入功能 用例设计思路
    Jmeter01 -mac下的安装
  • 原文地址:https://www.cnblogs.com/ljy-20180122/p/12371929.html
Copyright © 2020-2023  润新知