Ubuntu under Postgre and PostGIS installation

Source: Internet
Author: User
Tags postgresql psql postgis

Uninstall old version
sudo dpkg--purge PostGIS Postgresql-9.3-postgis

1. Install Postgresql$sudo Apt-cache Search PostgreSQL//Find the latest PostgreSQL package $sudo gem apt-get install PostgreSQL package name//select Package name for installation

2. Set Postgres user password
sudo passwd postgres3, landing PostgreSQL,
$sudo-U postgres psql

4. Connecting PostgreSQL and PostGIS (the ability to give the PostgreSQL spatial database)

$ create EXTENSION PostGIS; (Note whether you want to create it under your own database)
CREATE EXTENSION
$ CREATE EXTENSION postgis_topology; (Support topology)
CREATE EXTENSION

Error occurred
postgres=# CREATE EXTENSION PostGIS; ERROR:  "/usr/share/postgresql/9.3/extension/postgis.control": No such File or Directorypostgres=# SELECT version ();

Solution Reference: Http://gis.stackexchange.com/questions/71302/error-when-trying-to-run-create-extension-postgis

sudo apt-get Install postgis*

Re-run

CREATE EXTENSION PostGIS;
CREATE EXTENSION postgis_topology;
Results are normal.

Restarting the database service
    1. sudo service postgresql restart
Configuring remote connections

1. Modify the postgresql.conf file to modify the listening mode of the database server to listen for connection requests made by all hosts.

Navigate to #listen_addresses= ' localhost '. After the PostgreSQL installation is complete, the default is to accept only connection requests that come in native localhost.

Remove line start # and modify line content to listen_addresses= ' * ' to allow the database server to listen for connection requests from any host

2. Modify the pg_hba.conf file to configure the user's access rights (#开头的行是注释内容):

    1. # TYPE DATABASE USER cidr-address METHOD
    2. # "Local" is for Unix domain sockets connections only
    3. Local all All trust
    4. # IPV4 Local connections:
    5. Host All 127.0.0.1/32 Trust
    6. Host All 192.168.1.0/24 MD5
    7. # IPV6 Local connections:
    8. Host all:: 1/128 Trust

7th is the newly added content that allows all hosts on the network segment 192.168.1.0 to access the database using all legitimate database usernames and provide encrypted password authentication.

Where the number 24 is the subnet mask, which means that the 192.168.1.0--192.168.1.255 computer is allowed access


Pgadmin connection after configuration complete, error occurred:
error connecting to Server:FATAL:password authentication failed for user Postgres

Workaround:

Using sudo-u postgres psql,

sudo -u postgres psql

login password  'postgres';

Changes will be successful with "ALTER ROLE" hint

Then use pgadmin to connect to the database OK

Ubuntu under Postgre and PostGIS installation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.