2009-07-14

PostgreSQL one click installer fails - SOLVED

I finally got around to upgrading my PostgreSQL 8.0 to latest, which is PostgreSQL 8.4 as of writing. I had used a fink (Debian APT version) of PostgreSQL before, but now I wanted it upgraded.

I found that EnterpriseDB - the commercial branch of PostgreSQL has got a "One Click Installer". Oh JOLLY, I merrily thought. I figured that I'll push it in and then I'll figure out how I'll deprecate my old install and transfer the DBs over (haven't done that as of writing).

Not totally surprising I ran into problems. The error message I got in the installer was:
Failed to initialise the database cluster with initdb

Hmmmm.... That's quite serious. I headed over to the support forum. Not long before I found the thread named "Error Installing Postgresql on OSx (Macbook Pro latest) using one click installation". It seems that the problem is that the previously installed postgres user is an "anonymous" one. I.e it doesn't have a shell nor a home directory. Until this oversight is fixed in the PostgreSQL/8.4/installer/server/createuser.sh script, you can do the following kung-fu-grips.
First, check that your postgres user really is screwed (command ran as root, if you're not using root, prefix the command with sudo as usual). Run this and see if you get something like this.
bash-3.2# dscl . read /users/postgres
AppleMetaNodeLocation: /Local/Default
Change: 0
Expire: 0
GeneratedUID: 00818549-E7C6-60A498CE64B5
NFSHomeDirectory: /dev/null
Password: *
PrimaryGroupID: 252
RealName:
PostgreSQL Database Server
RecordName: postgres
RecordType: dsRecTypeNative:users
UniqueID: 252
UserShell: /dev/null

You notice that NFSHomeDirectory has the value of /dev/null and that UserShell has got the value of /dev/null too. Run these commands to fix it:
dscl . -create /Users/postgres NFSHomeDirectory /Library/PostgreSQL/8.4
dscl . -create /Users/postgres UserShell /bin/bash

Note that if you're using another version than 8.4 you'll have to change the path. If you re-run the first command it should now look like this:
bash-3.2# dscl . read /users/postgres
AppleMetaNodeLocation: /Local/Default
Change: 0
Expire: 0
GeneratedUID: 00818549-B53E-60A498CE64B5
NFSHomeDirectory: /Library/PostgreSQL/8.4
Password: *
PrimaryGroupID: 252
RealName:
PostgreSQL Database Server
RecordName: postgres
RecordType: dsRecTypeNative:users
UniqueID: 252
UserShell: /bin/bash

Note that both NFSHomeDirectory and UserShell has got "proper values". You can now log in (from root shell) to postgres user (su postgres). If your previous attempt didn't work, delete the /Library/PostgreSQL/8.4 directory (folder) and you can now install PostgreSQL 8.4 with the one click installer from EnterpriseDB.

Hope that's of any use to anybody out there.

Oh, and one more thing:
PostgreSQL > MySQL > *

No comments: