the ubuntu way, part 1

August 29, 2006 under Computers, Linux, PostgreSQL, Software, Ubuntu

This might be the first part in a series. Ubuntu is unlike any Linux distro that I’ve ever used before. Its installation and quick ‘n’ painless and its ease-of-use are (currently) second to none. Ubuntu‘s package management app, Synaptic, is stellar. It allows you to easily install apps (and their depenecies) from a simple yet effective interface. However, one thing I’ve noticed is that when you install software via Synaptic, you’re installing it in a different way than you would when you build from source or even use another package management system like RedHat‘s RPM. Some installations via Synaptic pre-configure the software for you – you never really know when this will be the case. Last night, I discovered this while installing PostgreSQL 8.1.

For the benefit of myself and anyone else who becomes confused when following the documentation and being faced with plenty of errors, here’s what it took for me to make it work.

Once you’ve installed the PostgreSQL packages, fire up a terminal window. PostgreSQL cannot be run as root, but when it’s installed, it’s also not setup to use your regular login account. The installer creates a postgres user for you. So you need to create a password for this user:

$ sudo su postgres -c psql template1

You’ll now have a PostgreSQL prompt instead of a Bash (or whatever shell you’re using) prompt. Issue this to change the password of the postgres user:

ALTER USER postgres WITH PASSWORD 'your_chosen_password';
 
 \\q

Now all you need is a database. If you wanted to create one called, say ‘bestdbever’, enter the following at your shell prompt:

$ sudo su postgres -c createdb -O bestdbever postgres

Now you have a database that you can start creating a schema, tables, sprocs and more for. There’s no need to add anything to rc.local, as the package installer will create the daemon for you. You also don’t have to run initdb. Now when you’re developing an application with PHP, Ruby, C++ or whatever, you would connect with the postgres username and the password that you setup in the ALTER statement. This was mostly for my own reference, but maybe it’ll help somebody else.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
comments: 0 »

Leave a Reply

Your email address will not be published. Required fields are marked *

Comment

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>