If a man will begin with certainties, he shall end in doubts; but if he will be content to begin with doubts, he shall end in certainties.
F. Bacon , The Advancement Of Learning - 1605 A.D.
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.