{"id":58,"date":"2017-03-22T23:28:01","date_gmt":"2017-03-22T23:28:01","guid":{"rendered":"https:\/\/test.warrensoft.co.uk\/wp-test\/home-hub\/?p=58"},"modified":"2018-12-08T07:32:38","modified_gmt":"2018-12-08T07:32:38","slug":"software-database-server","status":"publish","type":"post","link":"https:\/\/test.warrensoft.co.uk\/wp-test\/2017\/03\/22\/software-database-server\/","title":{"rendered":"Software &#8211; Database Server"},"content":{"rendered":"<p>PostgreSQL is described as the world&#8217;s most advanced open-source database, and underpins a number of features of the home hub. It runs quite happily on the raspberry pi.<\/p>\n<pre>sudo apt-get install postgresql<\/pre>\n<p>There are three areas that require configuring, in order to allow the controller and website scripts to access the database. In addition, we should include access from our desktop PC, which will allow us to administer the database using the management tool pgAdmin.<\/p>\n<p>The first task is to edit the configuration file:<\/p>\n<pre>cd \/etc\/postgresql\/9.4\/main\r\nsudo nano postgresql.conf\r\n\r\n<\/pre>\n<p>Uncomment and modify the <em>listen_addresses<\/em> connection setting and change the value to &#8216;*&#8217; to listen on all interfaces. Save the file. Restart the database server.<\/p>\n<pre>sudo \/etc\/init.d\/postgresql restart<\/pre>\n<p>The next task is to edit pg_hba.conf to enable connections from localhost and your PC.<\/p>\n<pre>sudo nano pg_hba.conf<\/pre>\n<p>Edit the file to enable connections from your desktop machine&#8230;<\/p>\n<p># IPv4 local connections:<br \/>\nhost \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 all\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 all \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 client.ip.add.ress\/32 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 md5<\/p>\n<p>Access from the pi itself should already be configured&#8230;<\/p>\n<p># IPv6 local connections:<br \/>\nhost \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 all\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 all \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ::1\/128 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 md5<\/p>\n<p>save the file, and reload the configuration.<\/p>\n<pre>sudo \/etc\/init.d\/postgresql reload<\/pre>\n<p>The final task is to set the postgres user password. Replace &#8216;raspberry&#8217; with your chosen password.<\/p>\n<pre>sudo -u postgres psql -c \"alter user postgres password 'raspberry';\"<\/pre>\n<p>You should now be able to connect to the database server from\u00a0pgAdmin running on your client PC.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-191\" src=\"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-content\/uploads\/2017\/04\/PgAdmin-300x264.png\" alt=\"\" width=\"300\" height=\"264\" \/><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-690\" src=\"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-content\/uploads\/2017\/09\/PgAdmin-300x264.png\" alt=\"\" width=\"300\" height=\"264\" srcset=\"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-content\/uploads\/2017\/09\/PgAdmin-300x264.png 300w, https:\/\/test.warrensoft.co.uk\/wp-test\/wp-content\/uploads\/2017\/09\/PgAdmin.png 589w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>In the next post we will create a skeleton database.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PostgreSQL is described as the world&#8217;s most advanced open-source database, and underpins a number of features of the home hub. It runs quite happily on the raspberry pi. sudo apt-get install postgresql There are three areas that require configuring, in order to allow the controller and website scripts to access the database. In addition, we &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/test.warrensoft.co.uk\/wp-test\/2017\/03\/22\/software-database-server\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Software &#8211; Database Server&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"class_list":["post-58","post","type-post","status-publish","format-standard","hentry","category-hub-software-database"],"_links":{"self":[{"href":"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-json\/wp\/v2\/posts\/58","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-json\/wp\/v2\/comments?post=58"}],"version-history":[{"count":17,"href":"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-json\/wp\/v2\/posts\/58\/revisions"}],"predecessor-version":[{"id":691,"href":"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-json\/wp\/v2\/posts\/58\/revisions\/691"}],"wp:attachment":[{"href":"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-json\/wp\/v2\/media?parent=58"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-json\/wp\/v2\/categories?post=58"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/test.warrensoft.co.uk\/wp-test\/wp-json\/wp\/v2\/tags?post=58"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}