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 

  • 相关阅读:
    WPF之感触
    C# WinForm 给DataTable中指定位置添加列
    MyEclipse 8.6 download 官方下载地址
    将博客搬至CSDN
    Building Microservices with Spring Cloud
    Building Microservices with Spring Cloud
    Building Microservices with Spring Cloud
    Building Microservices with Spring Cloud
    Building Microservices with Spring Cloud
    Building Microservices with Spring Cloud
  • 原文地址:https://www.cnblogs.com/h-c-g/p/15177527.html
Copyright © 2011-2022 走看看