zoukankan      html  css  js  c++  java
  • 测试PostGIS是否安装成功

     

    PostgreSQL操作-psql基本命令

     

    测试PostGIS是否安装成功

    接入PostgreSQL数据库: psql -h IP地址 -p 端口 -U 数据库名

    Microsoft Windows [版本 10.0.18363.1316]
    (c) 2019 Microsoft Corporation。保留所有权利。
    
    
    #######连接登录postgresql数据库
    C:Userszhao>psql -U postgres -h localhost -d postgres -p 5432
    用户 postgres 的口令:
    psql (11.2)
    输入 "help" 来获取帮助信息.
    
    #######创建test数据库
    postgres=# create database test;
    CREATE DATABASE
    
    #######切换test数据库
    postgres=# c test;
    您现在已经连接到数据库 "test",用户 "postgres".
    
    #######创建postgis扩展
    test=# create extension postgis;
    CREATE EXTENSION
    
    #######查询全部扩展
    test=# select postgis_full_version();
                                                                          postgis_full_version                              
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------
     POSTGIS="3.1.0 3.1.0" [EXTENSION] PGSQL="110" GEOS="3.9.0-CAPI-1.14.1" PROJ="7.1.1" LIBXML="2.9.9" LIBJSON="0.12" LIBPROTOBUF="1.2.1" WAGYU="0.5.0 (Internal)"
    (1 行记录)
    
    
    test=#

    配置数据库远程访问

    PG默认只能本机访问,但是实际情况中,应用服务器多单独部署,需要开通PG的远程访问权限,且是需要配置用户密码的。

    需要修改postgres.conf, pg_hba.conf文件。

    文件位置:

    D:oyz3dserverPostgreSQL11datapostgresql.conf
    D:oyz3dserverPostgreSQL11datapg_hba.conf
    修改postgresql.conf
    #listen_addresses='localhost'
    listen_addresses='*'   --- 修改成'*'全部ip都可以访问改数据库
    修改pg_hba.conf
    # TYPE  DATABASE        USER            ADDRESS                 METHOD
    
    # IPv4 local connections:
    host    all             all             127.0.0.1/32            md5
    # IPv6 local connections:
    host    all             all             ::1/128                 md5
    # Allow replication connections from localhost, by a user with the
    # replication privilege.
    host    replication     all             127.0.0.1/32            md5
    host    replication     all             ::1/128                 md5
    host    all             all             0.0.0.0/0               md5   --添加本行数据

    注意: 重启pg数据库

    到test数据库的表找一个字段看下是否可以设置这个类型

     

     sql 例子:  select st_astext(shape) from table_name 

  • 相关阅读:
    spring集成环境下的axis webservice的发布,调试
    Axis2 webservice 之使用java调用webservice
    Axis2 webservice入门--写个简单的webservice
    Axis2 webservice入门--开发环境搭建,概念理解
    使用js给页面显示的图片添加水印效果
    java使用dom4j解析xml文件
    一个Java递归程序
    Java-Scanner键盘输入
    JVM—调优参数学习
    JVM—类加载过程
  • 原文地址:https://www.cnblogs.com/h-c-g/p/15177527.html
Copyright © 2011-2022 走看看