1

I have multiple installations of PostgreSQL on my machine, and would like to narrow down to a single installation (MacPorts flavor).

I believe that OSX comes shipped with some sort of package, but I am not aware of where it gets put, or how to troubleshoot where to find it and uninstall.

This has been a huge headache for me, so any help would be appreciated. I'm running 10.7.5.

which postgres yields:

/usr/local/pgsql/bin/postgres

And in my bash profile, I have:

PG_SQL=/usr/local/pgsql/lib:/usr/local/pgsql/bin
export PG_SQL

port installed yields:

postgresql92 @9.2.2_0 (active) 
postgresql_select @0.1_0 (active)

sh-3.2# find . -iname PG_VERSION yields:

./postgres/database/base/1/PG_VERSION
./postgres/database/base/12265/PG_VERSION
./postgres/database/base/12270/PG_VERSION
./postgres/database/base/16384/PG_VERSION
./postgres/database/PG_VERSION

that is relative to /Users, btw.

Patrick Mevzek
  • 9,921
  • 7
  • 32
  • 43
jml
  • 153
  • 1
  • 5

1 Answers1

2

OS X comes with a system Postgres (installed with the base OS, scattered all over, and NOT something you should attempt to uninstall).

If you have no specific Postgres version requirements, use the version installed with OS X.

If you require a specific version of Postgres my suggestion is that you install it from source (following the instructions in the Postgres manual), and place it somewhere where it will not conflict with the Postgres that comes with OS X (/usr/local/pgsql is a good location. You can also install it under your home directory if you really want to).
You can then set your PATH environment variable so the Postgres binary directory you just installed comes before /usr/bin, and when you run psql or other tools you'll be using the ones you installed rather than the ones that come with OS X.

(If you have multiple versions of Postgres installed you can uninstall the non-vendor-supplied ones in accordance with the instructions provided by the tool you used to install them. If you want to uninstall Postgres installed from source simply delete the directory it was installed to.)

voretaq7
  • 79,879
  • 17
  • 130
  • 214
  • 1
    I should mention that I ended up using the macports install anyway, because of dependencies with another library (was just easier). That install ended up in `/opt/local/bin/postgres`. All seems to be fine now, and defaulting correctly upon a reboot of the machine. – jml Feb 25 '13 at 20:37
  • I think MacPorts sets your path up for you, and the location it installs to (`/opt/local`) is safe from OS X upgrades trashing things, so you should be fine with that too. – voretaq7 Feb 25 '13 at 20:50
  • or just use HomeBrew that will let you install "any" postgreSQL version without conflicts between them nor the system one, and now even with simple upgrades thanks to `brew brew-postgresql-upgrade-database` – Patrick Mevzek Mar 08 '18 at 19:44