Skip to content

Initialize_PostgreSQL_Server

BenjaminWaldron edited this page Mar 5, 2005 · 6 revisions

HOW TO initialize PostgreSQL server

  • [http://www.postgresql.org/download/ PostgreSQL server] version 7.4 or above must be running either on the local machine or remotely over a TCP/IP port. You should use the --locale=C option when initializing the server with initdb.

  • Create user accounts.

  • Configure access privileges.

  • Restart PostgreSQL server.

Create User Accounts

  • Open a shell as user postgres. E.g. (Linux)
[user@localhost]$ su
[root@localhost]$ su postgres
[postgres@localhost]$
  • Create a user (lexdb) who will manage the database:

{{{[postgres@localhost]$ createuser --createdb --no-adduser -P lexdb Enter password for new user: Enter it again: CREATE USER}}}

  • (Note: setting the password to lexdb will save bother later.)
  • Create a user account for yourself (substitute your shell login for USERNAME below):

{{{[postgres@localhost]$ createuser --no-createdb --no-adduser -P USERNAME Enter password for new user: Enter it again: CREATE USER}}}

  • (Note: setting the password to match the username will save bother later.)

SET ACCESS PRIVILEGES

PostgreSQL server running on local machine

{{{# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD

local all all md5 host all all 127.0.0.1 255.255.255.255 md5}}}

  • TCP/IP must be enabled. Uncomment the line for TCP/IP in $PGDATA/postgresql.conf so that it reads:

     tcpip_socket = true

PostgreSQL server on remote machine

  • Allow remote access to the server by adding lines of the following form to access privilege configuration file $PGDATA/pg_hba.conf:

host    all         all        IP_ADDRESS    255.255.255.255     md5

  • TCP/IP must be enabled. Uncomment the line for TCP/IP in $PGDATA/postgresql.conf so that it reads:

    • tcpip_socket = true
  • By default the server will run on port 5432. To use another port set the environment variable PGPORT.

Clone this wiki locally