http://stackoverflow.com/questions/8037729/completely-uninstall-postgresql-9-0-4-from-mac-osx-lion
After the uninstallation, I installed postgres by homebrew:
$brew update
$brew install postgres
OK, now I've installed postgres successfully. It's time to lauch the postgres server by:
$pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
and check it is running:
$ps aux | grep postgres
Everything works as expected, and I tried to run rails but got an error:
FATAL: role "dashboard" does not exist
It seems that I don't have that role created in postgres. Not a problem, it's easy to create a role by:
$createuser -P dashboard
Log into postgres and check the role:
$psql -d postgres -U [login user name]
postgres=# SELECT rolname FROM pg_roles;
rolname
---------------------
...
dashboard
Good! The role "dashboard" has been created successfully. Now try rails again. What? another error again?
PG::InsufficientPrivilege: ERROR: permission denied to create database
Looks like the role "dashboard" doesn't have the permission to create database. Check the permission for "dashboard" in postgres:
postgres=# \du
List of roles
Role name | Attributes | Member of
---------------------+------------------------------------------------+----------
dashboard | | {}
Yeah, no permission at all for "dashboard". Grant it appropriate permission:
postgres=# ALTER ROLE dashboard CREATEROLE CREATEDB;
Now, run the rails again. Sigh...another error again:
"dashboard_development" does not exist
PG::InsufficientPrivilege: ERROR: permission denied to create database
Looks like the role "dashboard" doesn't have the permission to create database. Check the permission for "dashboard" in postgres:
postgres=# \du
List of roles
Role name | Attributes | Member of
---------------------+------------------------------------------------+----------
dashboard | | {}
Yeah, no permission at all for "dashboard". Grant it appropriate permission:
postgres=# ALTER ROLE dashboard CREATEROLE CREATEDB;
Now, run the rails again. Sigh...another error again:
"dashboard_development" does not exist
I see. It's most likely because I didn't do db:create and db:migrate. So, let me do it:
$bundle exec rake db:create db:migrate
Well, finally the website is up and running!