<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>hocuspokus &#187; postgresql</title>
	<atom:link href="http://hocuspokus.net/tag/postgresql/feed" rel="self" type="application/rss+xml" />
	<link>http://hocuspokus.net</link>
	<description>the life and times of a code monkey</description>
	<lastBuildDate>Tue, 01 Jun 2010 16:40:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Using PostgreSQL With Ruby on Rails on OS&#160;X</title>
		<link>http://hocuspokus.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fhocuspokus.net%2F2008%2F11%2Fusing-postgresql-with-ruby-on-rails-on-os-x&amp;seed_title=Using+PostgreSQL+With+Ruby+on+Rails+on+OS%26%23160%3BX</link>
		<comments>http://hocuspokus.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fhocuspokus.net%2F2008%2F11%2Fusing-postgresql-with-ruby-on-rails-on-os-x&amp;seed_title=Using+PostgreSQL+With+Ruby+on+Rails+on+OS%26%23160%3BX#comments</comments>
		<pubDate>Sun, 16 Nov 2008 15:45:01 +0000</pubDate>
		<dc:creator>Daz</dc:creator>
				<category><![CDATA[postgresql]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby-on-rails]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://hocuspokus.net/?p=274</guid>
		<description><![CDATA[Following on from my last post for getting PostgreSQL up and running nicely on Mac OS X, my next task was getting it playing nicely with ruby on rails - I&#8217;m off on a rails course next week so I&#8217;m &#8230; <a href="http://hocuspokus.net/feeder/?FeederAction=clicked&#38;feed=Articles+%28RSS2%29&#38;seed=http%3A%2F%2Fhocuspokus.net%2F2008%2F11%2Fusing-postgresql-with-ruby-on-rails-on-os-x&#38;seed_title=Using+PostgreSQL+With+Ruby+on+Rails+on+OS%26%23160%3BX">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Following on from my <a href="http://hocuspokus.net/2008/11/16/install-postgresql-on-mac-os-x-leopard/">last post</a> for getting PostgreSQL up and running nicely on Mac OS X, my next task was getting it playing nicely with ruby on rails - I&#8217;m off on a rails course next week so I&#8217;m getting stuff ready. <img src='http://hocuspokus.net/wp-content/plugins/smilies-themer/tango/face-smile.png' alt=':)' class='wp-smiley' /> </p>

<p>It appears that there is currently two/three gem packages for using postgresql with ruby: <code>postgres</code>, <code>ruby-pg</code>, and <code>pg</code> - and from what I can make out, they&#8217;re all maintained by the same team now, (<code>postgres</code> was the original package, but it got abandoned - <code>ruby-pg</code> and <code>pg</code> are the replacements).  As such, i&#8217;ll go with the newer <code>ruby-pg</code> gem&#8230;</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">env</span> <span style="color: #007800;">ARCHFLAGS</span>=<span style="color: #ff0000;">&quot;-arch i386&quot;</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> \
 ruby-pg <span style="color: #660033;">--</span> \
 <span style="color: #660033;">--with-pgsql-lib</span>=<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>postgresql83 \
 <span style="color: #660033;">--with-pgsql-include</span>=<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>postgresql83</pre></div></div>


<p>Then finally, when writing the <code>database.yml</code> entry for connecting to postgresql, we have to define our adapter as follows:</p>


<div class="wp_syntax"><div class="code"><pre class="yaml" style="font-family:monospace;">development:
  adapter: postgresql
  database: test_dev
  encoding: unicode
  host: localhost
  user: XXXXX
  password: XXXXX
  timeout: 5000</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://hocuspokus.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fhocuspokus.net%2F2008%2F11%2Fusing-postgresql-with-ruby-on-rails-on-os-x&amp;seed_title=Using+PostgreSQL+With+Ruby+on+Rails+on+OS%26%23160%3BX/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Install PostgreSQL on Mac OS X&#160;Leopard</title>
		<link>http://hocuspokus.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fhocuspokus.net%2F2008%2F11%2Finstall-postgresql-on-mac-os-x-leopard&amp;seed_title=Install+PostgreSQL+on+Mac+OS+X%26%23160%3BLeopard</link>
		<comments>http://hocuspokus.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fhocuspokus.net%2F2008%2F11%2Finstall-postgresql-on-mac-os-x-leopard&amp;seed_title=Install+PostgreSQL+on+Mac+OS+X%26%23160%3BLeopard#comments</comments>
		<pubDate>Sun, 16 Nov 2008 10:57:42 +0000</pubDate>
		<dc:creator>Daz</dc:creator>
				<category><![CDATA[mac]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[datbase]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://hocuspokus.net/?p=248</guid>
		<description><![CDATA[This type of guide is all over the internet, but I&#8217;m too lazy to search for one every time I want to do this. So here&#8217;s a brief overview of how I got PostgreSQL set-up nicely on Mac OS 10.5&#8230; &#8230; <a href="http://hocuspokus.net/feeder/?FeederAction=clicked&#38;feed=Articles+%28RSS2%29&#38;seed=http%3A%2F%2Fhocuspokus.net%2F2008%2F11%2Finstall-postgresql-on-mac-os-x-leopard&#38;seed_title=Install+PostgreSQL+on+Mac+OS+X%26%23160%3BLeopard">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This type of guide is all over the internet, but I&#8217;m too lazy to search for one every time I want to do this. <img src='http://hocuspokus.net/wp-content/plugins/smilies-themer/tango/face-wink.png' alt=';)' class='wp-smiley' /> So here&#8217;s a brief overview of how I got PostgreSQL set-up nicely on Mac OS 10.5&#8230;</p>

<h4>Setting Up Our Environment</h4>

<p>Using a text editor of your choice, add the following lines to the bottom of the <code>/etc/profile</code> file (you&#8217;ll need to be an administrator to do this):</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># MacPorts</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PATH</span>=<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>sbin:<span style="color: #007800;">$PATH</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># PostgreSQL</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PATH</span>=<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>postgresql83<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #007800;">$PATH</span></pre></div></div>


<p>Now before we move on, make sure that you have <a href="http://www.macports.org/">MacPorts</a> installed.</p>

<p><span id="more-248"></span></p>

<h4>Installing PostgreSQL with MacPorts</h4>

<p>I like MacPorts - it makes installing general Unix packages and keeping them up-to-date a snap.  As such, we&#8217;ll use it to do the heavy lifting for installing PostgreSQL.  Open up a terminal and hit up the following command:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> port <span style="color: #c20cb9; font-weight: bold;">install</span> postgresql83 postgresql83-server</pre></div></div>


<p>Sit back and wait a while&#8230;  That&#8217;s the basic install done.</p>

<p>Now to configure it, do the following:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>db<span style="color: #000000; font-weight: bold;">/</span>postgresql83<span style="color: #000000; font-weight: bold;">/</span>defaultdb
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chown</span> postgres:postgres <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>db<span style="color: #000000; font-weight: bold;">/</span>postgresql83<span style="color: #000000; font-weight: bold;">/</span>defaultdb
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">su</span> postgres <span style="color: #660033;">-c</span> <span style="color: #ff0000;">'/opt/local/lib/postgresql83/bin/initdb -D /opt/local/var/db/postgresql83/defaultdb'</span></pre></div></div>


<p>This installs a default database instance for us to be getting on with.  Next, run this command to get PostgreSQL to start on system boot:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> launchctl load <span style="color: #660033;">-w</span> <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>LaunchDaemons<span style="color: #000000; font-weight: bold;">/</span>org.macports.postgresql83-server.plist</pre></div></div>


<p>Reboot your Mac.</p>

<h4>Creating a User Account and Database</h4>

<p>Once your Mac is back up, we finally need to create an account for us to use (substitute &#8216;daz&#8217; for your username)&#8230;</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">createuser <span style="color: #660033;">--superuser</span> daz <span style="color: #660033;">-U</span> postgres</pre></div></div>


<p>Now a database to play with&#8230;</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">createdb test_db</pre></div></div>


<h4>Admin Your Database with pgAdmin 3</h4>

<p>Download <a href="http://www.pgadmin.org/">pgAdmin</a>, then run the following commands to set up some functions that allows pgAdmin to collect statistics about your databases:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>postgresql83<span style="color: #000000; font-weight: bold;">/</span>contrib<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">su</span> postgres <span style="color: #660033;">-c</span> psql <span style="color: #000000; font-weight: bold;">&lt;</span> adminpack.sql</pre></div></div>


<p>That&#8217;s it - job done!<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup></p>

<div class="footnotes">
<hr />
<ol>

<li id="fn:1">
<p>For notes on making the database accessible over the network, please refer to one of my posts on <a href="http://hocuspokus.net/2008/05/13/install-postgresql-on-ubuntu-804/">PostgreSQL on Ubuntu</a>.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://hocuspokus.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fhocuspokus.net%2F2008%2F11%2Finstall-postgresql-on-mac-os-x-leopard&amp;seed_title=Install+PostgreSQL+on+Mac+OS+X%26%23160%3BLeopard/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Install PostgreSQL on Ubuntu&#160;8.04</title>
		<link>http://hocuspokus.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fhocuspokus.net%2F2008%2F05%2Finstall-postgresql-on-ubuntu-804&amp;seed_title=Install+PostgreSQL+on+Ubuntu%26%23160%3B8.04</link>
		<comments>http://hocuspokus.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fhocuspokus.net%2F2008%2F05%2Finstall-postgresql-on-ubuntu-804&amp;seed_title=Install+PostgreSQL+on+Ubuntu%26%23160%3B8.04#comments</comments>
		<pubDate>Tue, 13 May 2008 16:19:41 +0000</pubDate>
		<dc:creator>Daz</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[noteworthy]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://hocuspokus.net/?p=145</guid>
		<description><![CDATA[Following up from my old guide to installing PostgreSQL (for Ubuntu 7.10), I thought i&#8217;d better do an update for the latest releases&#8230; This quick walk-through are my notes for installing the PostgreSQL database server and the PgAdmin administration application &#8230; <a href="http://hocuspokus.net/feeder/?FeederAction=clicked&#38;feed=Articles+%28RSS2%29&#38;seed=http%3A%2F%2Fhocuspokus.net%2F2008%2F05%2Finstall-postgresql-on-ubuntu-804&#38;seed_title=Install+PostgreSQL+on+Ubuntu%26%23160%3B8.04">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Following up from my old guide to installing PostgreSQL (for Ubuntu 7.10), I thought i&#8217;d better do an update for the latest releases&#8230; <img src='http://hocuspokus.net/wp-content/plugins/smilies-themer/tango/face-smile.png' alt=':)' class='wp-smiley' /> </p>

<p>This quick walk-through are my notes for installing the PostgreSQL database server and the PgAdmin administration application on Ubuntu Linux, and also set up the server so it allows access to other PC&#8217;s on your network.</p>

<p>Before we move on, this guide was tested on the current release of Ubuntu Linux, (8.04 - Hardy Heron) and PostgreSQL 8.3, but it should also be applicable to older versions (of Ubuntu and PostgreSQL) and other Debian based distros.</p>

<p><span id="more-145"></span></p>

<p>Right for the basic installation, at the command-line, enter the following commands (or search for the listed packages in synaptic if you prefer that way of working):</p>

<pre><code>$ sudo apt-get install postgresql postgresql-client postgresql-contrib
$ sudo apt-get install pgadmin3
</code></pre>

<p>This installs the database server/client, some extra utility scripts and the pgAdmin GUI application for working with the database.</p>

<p>Now we need to reset the password for the &#8216;postgres&#8217; admin account for the server, so we can use this for all of the system administration tasks. Type the following at the command-line (substitute in the password you want to use for your administrator account):</p>

<pre><code>$ sudo su postgres -c psql template1
template1=# ALTER USER postgres WITH PASSWORD 'password';
template1=# \q
</code></pre>

<p>That alters the password for within the database, now we need to do the same for the unix user &#8216;postgres&#8217;:</p>

<pre><code>$ sudo passwd -d postgres
$ sudo su postgres -c passwd
</code></pre>

<p>Now enter the same password that you used previously.</p>

<p>Then, from here on in we can use both pgAdmin and command-line access (as the postgres user) to run the database server.  But before you jump into pgAdmin we should set-up the PostgreSQL admin pack that enables better logging and monitoring within pgAdmin.  Run the following at the command-line:</p>

<pre><code>$ sudo su postgres -c psql &lt; /usr/share/postgresql/8.3/contrib/adminpack.sql
</code></pre>

<p>Finally, we need to open up the server so that we can access and use it remotely - unless you only want to access the database on the local machine. To do this, first, we need to edit the postgresql.conf file:</p>

<pre><code>$ sudo gedit /etc/postgresql/8.3/main/postgresql.conf
</code></pre>

<p>Now, to edit a couple of lines in the &#8216;Connections and Authentication&#8217; section&#8230;</p>

<p>Change the line:</p>

<pre><code>#listen_addresses = 'localhost'
</code></pre>

<p>to</p>

<pre><code>listen_addresses = '*'
</code></pre>

<p>and also change the line:</p>

<pre><code>#password_encryption = on
</code></pre>

<p>to</p>

<pre><code>password_encryption = on
</code></pre>

<p>Then save the file and close gedit.</p>

<p>Now for the final step, we must define who can access the server. This is all done using the pg_hba.conf file.<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup></p>

<pre><code>$ sudo gedit /etc/postgresql/8.3/main/pg_hba.conf
</code></pre>

<p>Comment out, or delete the current contents of the file, then add this text to the bottom of the file:</p>

<pre><code># DO NOT DISABLE!
# If you change this first entry you will need to make sure that the
# database
# super user can access the database using some other method.
# Noninteractive
# access to all databases is required during automatic maintenance
# (autovacuum, daily cronjob, replication, and similar tasks).
#
# Database administrative login by UNIX sockets
local   all         postgres                          ident sameuser
# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

# "local" is for Unix domain socket connections only
local   all         all                               md5
# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
host    all         all         ::1/128               md5

# Connections for all PCs on the subnet
#
# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
host    all         all         [ip address]          [subnet mask]  md5
</code></pre>

<p>and in the last line, add in your subnet mask (i.e. 255.255.255.0) and the IP address of the machine that you would like to access your server (i.e. 138.250.192.115). However, if you would like to enable access to a range of IP addresses, just substitute the last number for a zero and all machines within that range will be allowed access (i.e. 138.250.192.0 would allow all machines with an IP address 138.250.192.x to use the database server).</p>

<p>That&#8217;s it, now all you have to do is restart the server:</p>

<pre><code>$ sudo /etc/init.d/postgresql-8.3 restart
</code></pre>

<p>And all should be working.</p>

<div class="footnotes">
<hr />
<ol>

<li id="fn:1">
<p>The following advice can also be given to you (plus you don&#8217;t even need to figure out IP addresses and subnet masks) from the latest versions of pgAdmin (1.6.x).  But it doesn&#8217;t hurt to know how things work.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://hocuspokus.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fhocuspokus.net%2F2008%2F05%2Finstall-postgresql-on-ubuntu-804&amp;seed_title=Install+PostgreSQL+on+Ubuntu%26%23160%3B8.04/feed</wfw:commentRss>
		<slash:comments>70</slash:comments>
		</item>
		<item>
		<title>Install phpPgAdmin on Ubuntu&#160;7.10</title>
		<link>http://hocuspokus.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fhocuspokus.net%2F2007%2F11%2Finstall-phppgadmin-on-ubuntu-710&amp;seed_title=Install+phpPgAdmin+on+Ubuntu%26%23160%3B7.10</link>
		<comments>http://hocuspokus.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fhocuspokus.net%2F2007%2F11%2Finstall-phppgadmin-on-ubuntu-710&amp;seed_title=Install+phpPgAdmin+on+Ubuntu%26%23160%3B7.10#comments</comments>
		<pubDate>Wed, 14 Nov 2007 20:14:32 +0000</pubDate>
		<dc:creator>Daz</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://hocuspokus.net/2007/11/14/install-phppgadmin-on-ubuntu-710/</guid>
		<description><![CDATA[Update: These instructions have been tested and work fine in the latest version of Ubuntu (8.04, Hardy Heron). phpPgAdmin is a web based GUI for administrating a PostgreSQL database server. Here&#8217;s some quick notes on getting it installed easily on &#8230; <a href="http://hocuspokus.net/feeder/?FeederAction=clicked&#38;feed=Articles+%28RSS2%29&#38;seed=http%3A%2F%2Fhocuspokus.net%2F2007%2F11%2Finstall-phppgadmin-on-ubuntu-710&#38;seed_title=Install+phpPgAdmin+on+Ubuntu%26%23160%3B7.10">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p class="alert"><strong>Update:</strong> These instructions have been tested and work fine in the latest version of Ubuntu (8.04, Hardy Heron).</p>

<p><a href="http://www.phppgadmin.org/">phpPgAdmin</a> is a web based GUI for administrating a <a href="http://www.postgresql.org/">PostgreSQL</a> database server.</p>

<p>Here&#8217;s some quick notes on getting it installed easily on Ubuntu 7.10&#8230;</p>

<p>In the terminal enter the following:</p>

<pre><code>$ sudo apt-get install phppgadmin
</code></pre>

<p>This will set up and install all of the phpPgAdmin packages.  It will also set-up and configure Apache and php5 for you too if you haven&#8217;t installed these already.</p>

<p>Next we need to create a symlink to phpPgAdmin so that Apache can find it:</p>

<pre><code>$ sudo ln -s /etc/phppgadmin/apache.conf /etc/apache2/conf.d/phppgadmin.conf
</code></pre>

<p>Now if you navigate to <a href="http://localhost/phppgadmin">http://localhost/phppgadmin</a> you should be greeted with the phpPgAdmin screen.  If your user account has a PostgreSQL account however, you will be logged in automagically.</p>

<p>Optionally, if you would like to be able to use the phpPgAdmin interface as the default &#8216;postgres&#8217; administration account,<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> you will need to do the following<sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup>&#8230;</p>

<pre><code>$ sudo gedit /usr/share/phppgadmin/conf/config.inc.php
</code></pre>

<p>Now find and change the following line</p>

<pre><code>$conf['extra_login_security'] = true;
</code></pre>

<p>to</p>

<pre><code>$conf['extra_login_security'] = false;
</code></pre>

<p>Save and close gedit.  Now all you need to do is restart Apache.</p>

<pre><code>$ sudo /etc/init.d/apache2 reload
</code></pre>

<p>Now if you head on over to <a href="http://localhost/phppgadmin">http://localhost/phppgadmin</a> all should be ready for you.</p>

<div class="footnotes">
<hr />
<ol>

<li id="fn:1">
<p>I am assuming here that you have set-up your PostgreSQL server using my <a href="http://hocuspokus.net/2007/11/05/install-posgresql-on-ubuntu-710/">set-up instructions</a> and therefore have a password protected &#8216;postgres&#8217; account and that logins require passwords.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:2">
<p>Please make sure you have read the above footnote and understand the security implications of allowing this type of access to your database server - if you have not secured your administration accounts, do it now!&#160;<a href="#fnref:2" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://hocuspokus.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fhocuspokus.net%2F2007%2F11%2Finstall-phppgadmin-on-ubuntu-710&amp;seed_title=Install+phpPgAdmin+on+Ubuntu%26%23160%3B7.10/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Creating New Accounts in&#160;PostgreSQL</title>
		<link>http://hocuspokus.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fhocuspokus.net%2F2007%2F11%2Fcreating-new-accounts-in-postgresql&amp;seed_title=Creating+New+Accounts+in%26%23160%3BPostgreSQL</link>
		<comments>http://hocuspokus.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fhocuspokus.net%2F2007%2F11%2Fcreating-new-accounts-in-postgresql&amp;seed_title=Creating+New+Accounts+in%26%23160%3BPostgreSQL#comments</comments>
		<pubDate>Mon, 05 Nov 2007 20:13:41 +0000</pubDate>
		<dc:creator>Daz</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://hocuspokus.net/2007/11/05/creating-new-accounts-in-postgresql/</guid>
		<description><![CDATA[Getting a new account set up on PostgreSQL is a simple process&#8230; Create our new user: $ sudo su postgres -c createuser daz Then you have to give this new user role a name (I called it daz), and then &#8230; <a href="http://hocuspokus.net/feeder/?FeederAction=clicked&#38;feed=Articles+%28RSS2%29&#38;seed=http%3A%2F%2Fhocuspokus.net%2F2007%2F11%2Fcreating-new-accounts-in-postgresql&#38;seed_title=Creating+New+Accounts+in%26%23160%3BPostgreSQL">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Getting a new account set up on PostgreSQL is a simple process&#8230;</p>

<p>Create our new user:</p>

<pre><code>$ sudo su postgres -c createuser daz
</code></pre>

<p>Then you have to give this new user role a name (I called it daz), and then say &#8216;y&#8217; to the question &#8220;Shall the new role be a superuser?&#8221; if you want the user to be an administrator.</p>

<p>Give the user a database password (this does not have to be the same as their unix password):</p>

<pre><code>$ sudo su postgres -c psql
postgres=# ALTER USER daz WITH PASSWORD 'mypassword';
postgres=# \q
</code></pre>

<p>Finally, give the new user a database to play with:</p>

<pre><code>$ sudo su postgres -c createdb daz
</code></pre>

<p>Pretty straight forward&#8230; <img src='http://hocuspokus.net/wp-content/plugins/smilies-themer/tango/face-smile.png' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://hocuspokus.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fhocuspokus.net%2F2007%2F11%2Fcreating-new-accounts-in-postgresql&amp;seed_title=Creating+New+Accounts+in%26%23160%3BPostgreSQL/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Install PostgreSQL on Ubuntu&#160;7.10</title>
		<link>http://hocuspokus.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fhocuspokus.net%2F2007%2F11%2Finstall-postgresql-on-ubuntu-710&amp;seed_title=Install+PostgreSQL+on+Ubuntu%26%23160%3B7.10</link>
		<comments>http://hocuspokus.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fhocuspokus.net%2F2007%2F11%2Finstall-postgresql-on-ubuntu-710&amp;seed_title=Install+PostgreSQL+on+Ubuntu%26%23160%3B7.10#comments</comments>
		<pubDate>Mon, 05 Nov 2007 18:48:10 +0000</pubDate>
		<dc:creator>Daz</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[noteworthy]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[geek]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://hocuspokus.net/2007/11/05/install-posgresql-on-ubuntu-710/</guid>
		<description><![CDATA[If you are using the latest version of Ubuntu (8.04 - Hardy Heron), you might find these slightly updated instructions useful. This quick walk-through are my notes for installing the PostgreSQL database server and the PgAdmin administration application on Ubuntu &#8230; <a href="http://hocuspokus.net/feeder/?FeederAction=clicked&#38;feed=Articles+%28RSS2%29&#38;seed=http%3A%2F%2Fhocuspokus.net%2F2007%2F11%2Finstall-postgresql-on-ubuntu-710&#38;seed_title=Install+PostgreSQL+on+Ubuntu%26%23160%3B7.10">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p class="alert">If you are using the latest version of Ubuntu (8.04 - Hardy Heron), you might find these <a href="http://hocuspokus.net/2008/05/13/install-postgresql-on-ubuntu-804/">slightly updated instructions</a> useful.</p>

<p>This quick walk-through are my notes for installing the PostgreSQL database server and the PgAdmin administration application on Ubuntu Linux, and also set up the server so it allows access to other PC&#8217;s on your network.</p>

<p>Before we move on, this guide was tested on the current release of Ubuntu Linux, (7.10 - Gutsy Gibbon) and PostgreSQL 8.2, but it should also be applicable to older versions (of Ubuntu and PostgreSQL) and other Debian based distros.</p>

<p><span id="more-57"></span></p>

<p>Right for the basic installation, at the command-line, enter the following commands (or search for the listed packages in synaptic if you prefer that way of working):</p>

<pre><code>$ sudo apt-get install postgresql postgresql-client postgresql-contrib
$ sudo apt-get install pgadmin3
</code></pre>

<p>This installs the database server/client, some extra utility scripts and the pgAdmin GUI application for working with the database.</p>

<p>Now we need to reset the password for the &#8216;postgres&#8217; admin account for the server, so we can use this for all of the system administration tasks. Type the following at the command-line (substitute in the password you want to use for your administrator account):</p>

<pre><code>$ sudo su postgres -c psql template1
template1=# ALTER USER postgres WITH PASSWORD 'password';
template1=# \q
</code></pre>

<p>That alters the password for within the database, now we need to do the same for the unix user &#8216;postgres&#8217;:</p>

<pre><code>$ sudo passwd -d postgres
$ sudo su postgres -c passwd
</code></pre>

<p>Now enter the same password that you used previously.</p>

<p>Then, from here on in we can use both pgAdmin and command-line access (as the postgres user) to run the database server.  But before you jump into pgAdmin we should set-up the PostgreSQL admin pack that enables better logging and monitoring within pgAdmin.  Run the following at the command-line:</p>

<pre><code>$ sudo su postgres -c psql &lt; /usr/share/postgresql/8.2/contrib/adminpack.sql
</code></pre>

<p>Finally, we need to open up the server so that we can access and use it remotely - unless you only want to access the database on the local machine. To do this, first, we need to edit the postgresql.conf file:</p>

<pre><code>$ sudo gedit /etc/postgresql/8.2/main/postgresql.conf
</code></pre>

<p>Now, to edit a couple of lines in the &#8216;Connections and Authentication&#8217; section&#8230;</p>

<p>Change the line:</p>

<pre><code>#listen_addresses = 'localhost'
</code></pre>

<p>to</p>

<pre><code>listen_addresses = '*'
</code></pre>

<p>and also change the line:</p>

<pre><code>#password_encryption = on
</code></pre>

<p>to</p>

<pre><code>password_encryption = on
</code></pre>

<p>Then save the file and close gedit.</p>

<p>Now for the final step, we must define who can access the server. This is all done using the pg_hba.conf file.<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup></p>

<pre><code>$ sudo gedit /etc/postgresql/8.2/main/pg_hba.conf
</code></pre>

<p>Comment out, or delete the current contents of the file, then add this text to the bottom of the file:</p>

<p><pre># DO NOT DISABLE!</p>

<h1>If you change this first entry you will need to make sure that the</h1>

<h1>database</h1>

<h1>super user can access the database using some other method.</h1>

<h1>Noninteractive</h1>

<h1>access to all databases is required during automatic maintenance</h1>

<h1>(autovacuum, daily cronjob, replication, and similar tasks).</h1>

<p>#</p>

<h1>Database administrative login by UNIX sockets</h1>

<p>local   all         postgres                          ident sameuser</p>

<h1>TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD</h1>

<h1>"local" is for Unix domain socket connections only</h1>

<p>local   all         all                               md5</p>

<h1>IPv4 local connections:</h1>

<p>host    all         all         127.0.0.1/32          md5</p>

<h1>IPv6 local connections:</h1>

<p>host    all         all         ::1/128               md5</p>

<h1>Connections for all PCs on the subnet</h1>

<p>#</p>

<h1>TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD</h1>

<p>host    all         all         [ip address]          [subnet mask]  md5</pre></p>

<p>and in the last line, add in your subnet mask (i.e. 255.255.255.0) and the IP address of the machine that you would like to access your server (i.e. 138.250.192.115). However, if you would like to enable access to a range of IP addresses, just substitute the last number for a zero and all machines within that range will be allowed access (i.e. 138.250.192.0 would allow all machines with an IP address 138.250.192.x to use the database server).</p>

<p>That&#8217;s it, now all you have to do is restart the server:</p>

<pre><code>$ sudo /etc/init.d/postgresql-8.2 restart
</code></pre>

<p>And all should be working.</p>

<div class="footnotes">
<hr />
<ol>

<li id="fn:1">
<p>The following advice can also be given to you (plus you don&#8217;t even need to figure out IP addresses and subnet masks) from the latest versions of pgAdmin (1.6.x).  However, this is not the version that ships with Ubuntu, so i&#8217;ll leave these instructions here.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://hocuspokus.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fhocuspokus.net%2F2007%2F11%2Finstall-postgresql-on-ubuntu-710&amp;seed_title=Install+PostgreSQL+on+Ubuntu%26%23160%3B7.10/feed</wfw:commentRss>
		<slash:comments>63</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->