Database Installation Instructions
Database Installation Instructions
Prof. Hachadoorian
Spring 2021
Installing PostreSQL
These instructions discuss how to install PostgreSQL 13.x using the EnterpriseDB
installer. These instructions should work with Windows (which I have tested)
or with Mac (which I have not). Anyone running Linux should discuss with
me how to install PostgreSQL. Anyone running Windows or Mac who would
like to get experience with Linux should use OSGeoLive, which comes with
PostgreSQL/PostGIS installed, as well as a large number of FOSS geospatial
applications.
Download the PostreSQL installer from https://www.enterprisedb.com/downl
oads/postgres-postgresql-downloads. Download version 13.x, the most recent
point release.
Accept all defaults, including installing all components. Set the superuser
password to postgres. Of course, keep in mind that you would not want to pick
an easily guessable password in a production environment.
This process installs the database server software and initialize a database
cluster running on port 5432. Usually a database server will only contain one
cluster, though it is possible to run multiple clusters, each on its own port. This
is unusual in a production environment, but may be done by developers for
testing purposes.
A cluster can contain multiple databases. Separate databases are usually
devoted to specific applications. A human resources database may be kept
separate from an inventory database. A database that is expected to sustain
heavy loads (many reads and writes) will usually be given its own database server.
A cluster is always initialized with a maintenance database named postgres,
but this database should not be used as a production database. We will create a
new database later.
When the installation is complete, you can launch Stack Builder immediately, or
you can exit the installer and run Stack Builder later.
1
Stack Builder
Stack Builder is used to add capabilities to a database cluster. We will use it to
add PostGIS to the cluster.
In the first step, select the PostgreSQL 13 (x64) on port 5432 installation.
(For a clean install, this should be the only option other than <remote server>.
If you have installed a different version (e.g. PostgreSQL 12.x) or selected a
different port during the installation process, the text in the dropdown will differ.
Hit Next.
Expand the tree branch for Spatial Extensions and select the most recent available
version of PostGIS (currently PostGIS 3.1 Bundle). Hit Next.
2
Provide the database connection information. If you have followed these instruc-
tions, this should be:
• User Name: postgres
• Password: postgres
• Port: 5432
You can name the database anything you want. I will recommend that you name
the database universe, so-called because it will contain all the data that we will
work with this semester. If you use a different name, when I refer to universe,
you should know that I am referring to the main database on your localhost.
Choose Yes for the following questions about setting environment variables for
working with rasters.
Hit Close. Control will return to the Stack Builder installer. Click Finish.
When I ran the installer, I did not have to restart my computer and the database
was immediately available. Do restart your computer at least once at some point,
especially if the server does not work as expected.
3
DBeaver
We will be using DBeaver as our management client. Download and install
the Community Edition (most recent version, 7.3.2 as of January 2021) from
https://dbeaver.io/download/.
Now connect to the PostGIS universe database that you created.
1. Go to Database→New Database Connection, or hit the plug icon at the
left of the top toolbar.
2. Select the PostgreSQL icon and hit Next.
3. In the next dialog, change the Database name to universe. If you have
followed these instructions, the username and password should both be
postgres. If you have created a different database name, username, or
password, use those names instead. Then hit Finish. Optionally, hit Test
Connection first, then hit Finish.
4
You should now see the database universe in the Database Navigator (left-hand
pane). You can connect to the database by clicking the triangle-arrow to expand
the tree. Using DBeaver will be demoed in class.
5
data is available through a server maintained by the department. The server is
only available on campus. In order to be able to work with this data off campus,
you have to duplicate this data on your local Postgres installation.
The file shakespeare_insert.sql can be downloaded from the Canvas course.
1. Lauch DBeaver.
2. Connect to universe (or the database you want to load this data into) by
selecting it in the Database Navigator.
3. Open a SQL Editor by hitting F3, or selecting SQL Editor→SQL Editor
in the menu.
4. Select SQL Editor→Import SQL Script from the menu. In the dialog, find
shakespeare_insert.sql and hit Open. This is a large file and may take
a few seconds to load.
5. Run the script by hitting Alt+X, or select SQL Editor→Execute SQL
Script from the menu. Note that there are several “Execute” options, so
make sure to select the correct one. We will discuss further in class.
The script will fail if any of the database objects already exist. If you end up
with a partially executed script, or make unintended changes to the tables and
need to start afresh, you will have to drop the shakespeare schema (and all the
tables it contains) before running this script again. Instructions are not provided
here, but we will discuss how to create and drop database objects in class.
Notes
PostGIS 3.0.1 bundle includes PostGIS 3.0.1 w GDAL 2.4.4 (SQLite 3.30.1, OpenJPEG 2.3.1, Exp
https://postgis.net/2020/02/20/postgis-3.0.1/
PostGIS "spatially enables" the PostgreSQL server, allowing it to be used as a backend spati
https://github.com/pgRouting/pgrouting/releases/tag/v3.0.0-rc1
pgRouting extensions PostGIS for building routing applications
https://github.com/pramsey/pgsql-ogr-fdw
ogr_fdw allows you to query flat files, relational databases, and web services to name a few
https://github.com/pgpointcloud/pointcloud
pgPointcloud introduces specialty types for storing point cloud data loaded from LIDAR.