Convalesco

Current revision: 0.11

Last update: 2026-03-26 10:51:09 +0000 UTC

The worst form of inequality is obtained when we try to make unequal things equal and the worst form of injustice happens when you're trying to treat equally those who are unequal.

Aristotle , Nicomachean Ethics - 350 B.C.


Macports and PostgreSQL

Date: 03/06/2015, 18:17

Category: technology

Revision: 1



I chose to go with PostgreSQL as my default DB for my next Rails project. In order to use PostgreSQL with MacPorts, all you need the following:


$ sudo port install postgresql92-server
$ sudo mkdir -p /opt/local/var/db/postgresql92/defaultdb
$ sudo chown postgres:postgres /opt/local/var/db/postgresql92/defaultdb
$ sudo su postgres -c '/opt/local/lib/postgresql92/bin/initdb -D /opt/local/var/db/postgresql922/defaultdb'
$ sudo port load postgresql92-server

Now postgreSQL will start at boot. You don’t have to manually start/stop the database anymore. In order to use a newer version, e.g. postgresql93-server, just change the version numbers.

When you first create install the database, only the user postgres will be available. I like to create a role with my username. To do that under OSX issue the following commands:


$ psql -U postgres
postgres=# CREATE ROLE atma;
postgres=# ALTER ROLE <username> WITH LOGIN CREATEDB;
postgres=# \q

Now you can create new databases using your username as role via command line using the createdb command:


$ createdb my_dev_db

Now you can add the relevant info to your application.