安装 Ubuntu 18.04 LTS(Bionic Beaver)
1.检查你的 Ubuntu 版本:- lsb_release -a
安装Postgresql
2.在服务器或您的电脑(终端)上
:- sudo apt-get update sudo apt-get install -y postgresql postgresql-contrib
创建数据库和用户以供访问
将DATABASE_NAME_HERE 和 USER_NAME_HERE替换 为您要使用的值。
# 这将提示您输入数据库密码...还请注意下面的大写字母“O”而不是数字“0”(零):-
3. sudo -u postgres createuser -P USER_NAME_HERE sudo -u postgres createdb -O USER_NAME_HERE DATABASE_NAME_HERE
测试与 Postgresql 的连接
4. psql -h localhost -U USER_NAME_HERE DATABASE_NAME_HERE Postgresql 将要求您输入密码。然后您应该看到以下内容:DATABASE_NAME_HERE =>要退出,请输入:- \q
向数据库添加 PostGIS-2.4 支持
5. sudo apt-get install -y postgis postgresql-10-postgis-2.4
sudo -u postgres psql -c "CREATE EXTENSION postgis; CREATE EXTENSION postgis_topology;" DATABASE_NAME_HERE
6. 最后...安装 PgAdmin3 并设置您的“服务”连接 sudo apt-get install pgadmin3
感谢 Jon Saints 于 2014 年 8 月 13 日发布的原始帖子(适用于 Ubuntu 14.04)
http://www.saintsjd.com/2014/08/13/howto-install-postgis-on-ubuntu-trusty.html
http://www.github.com/saintsjd
http://facebook.com/saintsjd
最后...您可以使用下面的命令检查您的终端输出:
:~$ sudo apt install -y postgresql postgresql-contrib
[sudo] password for xxxx:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
postgresql-doc
The following NEW packages will be installed
postgresql postgresql-contrib
0 to upgrade, 2 to newly install, 0 to remove and 27 not to upgrade.
Need to get 11.6 kB of archives.
After this operation, 127 kB of additional disk space will be used.
Get:1 http://gb.archive.ubuntu.com/ubuntu bionic/main amd64 postgresql all 10+190 [5,784 B]
Get:2 http://gb.archive.ubuntu.com/ubuntu bionic/main amd64 postgresql-contrib all 10+190 [5,796B]
Fetched 11.6 kB in 0s (101 kB/s)
Selecting previously unselected package postgresql.
(Reading database ... 399415 files and directories currently installed.)
Preparing to unpack .../postgresql_10+190_all.deb ...
Unpacking postgresql (10+190) ...
Selecting previously unselected package postgresql-contrib.
Preparing to unpack .../postgresql-contrib_10+190_all.deb ...
Unpacking postgresql-contrib (10+190) ...
Setting up postgresql-contrib (10+190) ...
Setting up postgresql (10+190) ...
:~$ sudo -u postgres createuser -P postgis
Enter password for new role: xxxx (your password)
Enter it again: xxxx (your password)
:~$ sudo -u postgres createdb -O postgis webgis
createdb: database creation failed: ERROR: database "webgis" already exists
:~$ sudo -u postgres createdb -O postgis polybase
:~$ psql -h localhost -U postgis polybase
Password for user postgis:
psql (10.6 (Ubuntu 10.6-0ubuntu0.18.04.1), server 9.6.8)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.
polybase=>
\q
:~$ sudo apt install -y postgis postgresql-10-postgis-2.4
Reading package lists... Done
Building dependency tree
Reading state information... Done
postgis is already the newest version (2.4.3+dfsg-4).
The following NEW packages will be installed
libprotobuf-c1 postgresql-10-postgis-2.4
0 to upgrade, 2 to newly install, 0 to remove and 27 not to upgrade.
Need to get 578 kB of archives.
After this operation, 1,748 kB of additional disk space will be used.
Get:1 http://gb.archive.ubuntu.com/ubuntu bionic/universe amd64 libprotobuf-c1 amd64 1.2.1-2[19.0 kB]
Get:2 http://gb.archive.ubuntu.com/ubuntu bionic/universe amd64 postgresql-10-postgis-2.4 amd64 2.4.3+dfsg-4 [559 kB]
Fetched 578 kB in 0s (2,861 kB/s)
Selecting previously unselected package libprotobuf-c1:amd64.
(Reading database ... 399421 files and directories currently installed.)
Preparing to unpack .../libprotobuf-c1_1.2.1-2_amd64.deb ...
Unpacking libprotobuf-c1:amd64 (1.2.1-2) ...
Selecting previously unselected package postgresql-10-postgis-2.4.
Preparing to unpack .../postgresql-10-postgis-2.4_2.4.3+dfsg-4_amd64.deb ...
Unpacking postgresql-10-postgis-2.4 (2.4.3+dfsg-4) ...
Setting up libprotobuf-c1:amd64 (1.2.1-2) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Setting up postgresql-10-postgis-2.4 (2.4.3+dfsg-4) ...
:~$ sudo -u postgres psql -c "CREATE EXTENSION postgis; CREATE EXTENSION postgis_topology;"polybase
ERROR: syntax error at or near "polybase"
LINE 1: ...XTENSION postgis; CREATE EXTENSION postgis_topology;polybase
^
:~$ sudo apt install pgadmin4
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package pgadmin4 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'pgadmin4' has no installation candidate
:~$ sudo apt install pgadmin3
Reading package lists... Done
Building dependency tree
Reading state information... Done
pgadmin3 is already the newest version (1.22.2-4).
0 to upgrade, 0 to newly install, 0 to remove and 27 not to upgrade.
如果您喜欢此文章,请收藏、点赞、评论,谢谢,祝您快乐每一天。