-
Notifications
You must be signed in to change notification settings - Fork 24
Setup PostgreSQL on Raspbian (Stretch)
Install the postgresql
package:
$ sudo apt install postgresql
Switch to the postgres
user:
$ sudo -u postgres -i
Create user octoprint
:
[postgres]$ createuser --interactive -P
Enter name of role to add: octoprint
Enter password for new role:
Enter it again:
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n
Create database octoprint_filamentmanager
:
[postgres]$ createdb -O octoprint octoprint_filamentmanager
Per default PostgreSQL only accepts connections from localhost
. To make the database server available in your network you have to modify two config files.
In the /etc/postgresql/9.6/main/postgresql.conf
change the listen_addresses
to
listen_addresses = '*'
Then append the following line to /etc/postgresql/9.6/main/pg_hba.conf
host octoprint_filamentmanager octoprint 192.168.178.0/24 md5
Adapt the IP address to your network, e.g. if your server has the IP 192.168.0.25
use 192.168.0.0/24
instead. This allows all clients in your network to access the database. For more information see https://en.wikipedia.org/wiki/Subnetwork
The final step is to restart the PostgreSQL service:
$ sudo systemctl restart postgresql.service
Follow the instructions from the Arch Linux setup guide.
If you encounter issues during the installation of the psycopg2
package make sure you have all required dependencies installed.
$ sudo apt install python-dev libpq-dev