Carnifex

From Knox Makers Wiki
Revision as of 17:44, 28 December 2014 by Laz (talk | contribs) (Created page with "Documenting progress steps for future repeat: ==Raspberry Pi== These steps were required to set up the raspberry pi ===Install postgresql=== *First, install postgresql as it...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documenting progress steps for future repeat:

Raspberry Pi

These steps were required to set up the raspberry pi

Install postgresql

  • First, install postgresql as it does not come installed on the RPi by default.
sudo apt-get install postgresql

Currently, the version installed by apt is 9.1. During installation, the postgresql daemon should be started and running as a service.

  • After installation, configuration of the default database and users should be performed. Use the command "psql" from terminal to access the postgresql interface. By default, psql accepts connections by peer only, no password. So to connect, you must be a superuser with name "postgres". "template1" is the name of the administrator database that you will need to connect to. So, to make changes to the default setup, enter:
su -u postgres psql template1
  • This command should enter you into the psql terminal. Here, we want to add a password to the user "postgres". By doing this, we will make it so that we can log in without superuser privileges by using a password instead. The command to change the user is:
ALTER USER with encrypted password '<password here>';

If successful, the terminal should acknowledge with "ALTER ROLE". If you did not receive an acknowledgement, double check the terminal semicolon was entered on the commond. After altering the role, press CTRL+d to exit psql.

  • Next, we have to change the authentication rules for postgresql to expect passwords and not peer privilege. The file "pg_hb.conf" configures the authentication. Open the file for editing:
sudo nano /etc/postgres/9.1/main/pg_hb.conf"

This file contains information about access from different network locations. In this case, we are wanting to change to password authentication for access for the "postgres" user when accessing from localhost. The header of the file contains lots of useful information, but the first uncommented line should be:

local     postgres            peer

The "peer" option should be changed to "md5". The line should read:

local    postgres         md5

Save and close the file. At this point, the postgresql service needs to be restarted to reload the configuration. Use the command:

sudo /etc/init.d/postgresql restart.

After the service has restarted, you can confirm that this change worked by entering the command:

psql -U postgres

You will be prompted for a password. This should be the password you entered using the "ALTER USER" command above. If this works, you should be in the psql terminal. Press CTRL+d to exit.

  • next create user