Postgres on Max OS X with MAMP

Last updated on
18 December 2021

At the moment I'm running MAMP Pro, but the setup should work with MAMP free version as well.

Requirments;
Download and install MAMP from MAMP

  1. Download and install postgres 8.4 or higher from Enterprise DB
  2. Add the bin directory of postgres, /Library/PostgreSQL/8.4/bin to the PATH in your .bashrc file in your home directory. Remember to run ./.bashrc to update the path.
    1. vi .bashrc (this opens the vi editor)
    2. i (this enters insert mode so you can edit the file, then add the path command, to your postgresql install, below to the first row
      1. export PATH=$PATH:/Library/PostgreSQL/14/bin
    3. <esc> (escape key exits insert mode)
    4. :w (this writes your addition to the file)
    5. :q (quit vi editor)
  3. Sudo to your root user and execute the following commands. '>' is the prompt on your terminal and should be excluded. Text in () is an explanation and should not be excluded. (For Mac users, look up documentation for enabling root user through the System Preferences.)
    1. > su postgres (log in as the postgres user)
    2. > createuser --no-createdb --no-password --interactive (choose a name for the role, and choose 'yes' as a super user role)
    3. > createuser --no-createdb --pwprompt devel (enter a password 'drupal', and choose as a superuser, this is if your site is using the standard devel user with password drupal)
    4. > exit
  4. Edit table at the bottom of the /Library/PostgreSQL/8.4/data/pg_hba.conf file to so that the options for local look like this. This states that the devel (or your user) must have a md5 password and all other users can log in with no password. (This is only recommended for your localhost and is not secure on a server)

    # "local" is for Unix domain socket connections only
    local all devel md5
    local all all trust

  5. In your applications folder stop and start the postgres server using the apps under the Postgres folder
  6. Log out of your root user
  7. Create your postgres database as specified in INSTALL.pgsql.txt:
    1. > createdb --encoding=UTF8 --owner=username databasename (The owner is devel or the user you created)

Help improve this page

Page status: No known problems

You can: