Postgresql 90 and macport

several day i try to install postgresql on my macbook, i find in google some  tutorial i always fail whet i practice. then I tried to understand what was really needed when the installation process, and finally I managed to install postgrest90-server

okey lets me start.


This guide assumes the following:

  • OS X Mountain Lion
  • The latest XCode
  • XCode Command Line Tools
  • The latest MacPorts


Make sure MacPorts is up to date, then install the postgresql90-server port:
{code}$ sudo port -v selfupdate
$ sudo port -v install postgresql90-server{/code}

Setup the Initial Database

Once the server has been installed, you will need to create the initial database:

$ sudo mkdir -p /opt/local/var/db/postgresql90/defaultdb
$ sudo chown postgres:postgres /opt/local/var/db/postgresql90/defaultdb
$sudo su postgres -c ‘/opt/local/lib/postgresql90/bin/initdb -D /opt/local/var/db/postgresql92/defaultdb’

i thins installation was complete but.. lets continue

Starting the Server

Once the initial database has been created, you can start the server.

To run the server manually, execute the following command:

{code}$ sudo su postgres -c ‘/opt/local/lib/postgresql90/bin/postgres -D /opt/local/var/db/postgresql90/defaultdb'{/code}

If you want the server to automatically start at boot time, execute the following command:

{code}$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql90-server.plist{/code}

Setup your PATH

The executable files for PostgreSQL are in a non-standard location, so you you’ll want to update your PATH to make things easier. Most likely, you’ll want to edit your ~/.bashrc or ~/.zshrc (or similar) profile, though you can set apply the changes for all users system-wide by editing /etc/profile.

Make sure you set the new path before /usr/bin to ensure that you are using the latest versions and not the default apple-supplied tools:
{code}export PATH=/opt/local/lib/postgresql90/bin:$PATH{/code}
You can verify this works by running which psql and you should see/opt/local/lib/postgresql90/bin/psql as the output.

Create a New User

You will be setup with a postgres user by default, but it is good practice to create a different user account.

To make things easy, create a new database user to match your OS X username:
{code}$ createuser –superuser <my username> -U postgres {/code}
You should now be able to create a new database:
{code}$ createdb my_app{/code}
Do please consider setting a password for your newly-created user 😉

reference :

Leave a Reply

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