Ubuntu Unleashed 2019 Edition: Covering 18.04, 18.10, 19.04

(singke) #1

should be able to use su to become this user, and no one will ever log in
directly as the user. (See Chapter 13, “Managing Users,” for more information
on how to add users to an Ubuntu system.) After you have added the user, you
can install each of the PostgreSQL packages you downloaded using the
standard dpkg -i command for a default installation.


Initializing the Data Directory in PostgreSQL


Installation initializes the database and sets the permissions on the data
directory to their correct values.


CAUTION
The initdb program sets the permissions on the data directory to 700 . To
avoid creating a security hole, you should not change these permissions to
anything else.

You can start the postmaster program with the following command
(making sure you are still the user postgres):


Click here to view code image
matthew@seymour:~$ postmaster -D /usr/local/pgsql/data &


If you have decided to use a directory other than
/usr/local/pgsql/data as the data directory, you should replace the
directory in the postmaster command line with whatever directory you are
using.


TIP
By default, Ubuntu makes the PostgreSQL data directory
/var/lib/pgsql/data. This is not a very good place to store the data,
however, because most people do not have the necessary space in the /var
partition for any kind of serious data storage. Note that if you change the
data directory to something else (such as /usr/local/pgsql/data, as
in the examples in this section), you need to edit the PostgreSQL startup file
(named postgres) located in /etc/init.d to reflect the change.

Creating a Database in PostgreSQL


Creating a database in PostgreSQL is straightforward, but it must be
performed by a user who has permissions to create databases in PostgreSQL
—for example, initially the user named postgres. You can then simply

Free download pdf