Install PostgreSQL on Mac OS X 10.5 Leopard
November 4th, 2007
How to install PostgreSQL on OS X 10.5 Leopard.
Avoid the MacPort
I’ve seen a few reports online that the MacPorts install of PostgreSQL currently fails on Leopard (I believe, due to pathing differences). I’ve seen a few workarounds posted, and some compiling themselves from source, but even then, I am still seeing people out of luck even after attempting these things.
I usually use MacPorts as a last resort and, instead, compile things myself for two reason:
- Paths - You are at the mercy of someone else’s locations for things on your machine. A MacPort often opts to place things in traditional UNIX paths rather than OS X’s standard paths. Maintaining existing conventions is more important than breaking convention in the name of tradition. With MacPorts, you end up with some things in UNIX-standard locations and some in Mac locations. If you compile yourself, you can place things in the proper Mac-specific locations, such as “/Library”, and maintain Apple’s established pathing conventions.
- Version - Compiling yourself usually means you can get the very latest version. MacPorts is sometimes a little behind the very latest.
But, why compile yourself when someone has already attended to the two criteria above and wrapped it up in a nice installer?
Install “PostgreSQL for Mac”
I am usually not a fan of one-click installers, again, because of the version lag. But, I came across a nice PostgreS installer by Dru Satori that has the latest version of PostgreSQL, has been tailored for Leopard, and also comes with some lightweight GUI tools for PostgreSQL. It is called “PostgreSQL for Mac” (PG4Mac) and can be downloaded here:
http://www.postgresqlformac.com
Download the “Unified Installer - X.X.X (alternate)” under Downloads on the left. It is important to download the alternate version. It is slightly newer.
There are three packages in the download: Developer, Client, and Server.
- Developer - The Developer package is not a full, runnable package, but exists solely for people that need to build against the static libraries rather than the shared.
- Client - The Client package contains no PostgreS database instance. It contains several, valuable client tools that allow you to create and back-up databases, create users, start and stop the PostgreS process, and visually browse and query the database. These tools are also included in the Server package.
- Server - The Server package installs an instance of the PostgreSQL database server and the Client tools. I prefer to have a local instance of the database, so the Server version is what I recommend you install on your development workstation. The installer places PostgreSQL and your data in the standard OS X location,
/Library/PostgreSQL8.
Install Server and Client Tools
If you’ve downloaded the Unified Installer successfully, there should be a PostgreSQL disk image on your Desktop.
- Open the disk image.
- Open the Server folder.
- Open PostgreSQL.mpkg.
- Follow the install process.
The Client tools are placed in a PostgreSQL folder in your Applications folder. I opted to move them to /Developer/Applications/PostgreSQL with my other development tools. Since they are .app files, you may simply drag and drop them anywhere you see fit.
Path Variable
We need to make sure the PostgreS command-line tools are accessible from any path. The installer intentionally omits this step because no installer is supposed to modify anything in /etc.
Edit the global Bash profile:
$ sudo nano /etc/profile
Add this line:
export PATH=/Library/PostgreSQL8/bin:$PATH
Ctrl-X to Exit. ”Y” to Save. ”Enter” to overwrite.
- Exit Terminal with “
exit” command and relaunch it. - Type
envto verify that the PATH variable now contains the PostgreS path. - Log in as Root [
su -] and runenvagain to verify that the PATH exists there too.
Set Default Character Set to UTF-8
PostgreSQL comes defaulted to “SQL ASCII”, an antiquated 7-bit, 128-character encoding from the 1970’s. The popular PostrgreS admin tool, pgAdmin, will even nag you if it detects the SQL ASCII encoding and will advise you to use UTF-8.
You cannot change the encoding of a database once it is created. The only way is to completely delete it and recreate it:
$ sudo rm -R /Library/PostgreSQL8/data |
Now recreate the database. Note that you must be the “postgres” user to do this, which we are doing with the “sudo -u postgres” portion below. The -E parameter of initdb tells PostgreS to use UTF-8 – the standard, modern, universal character set:
$ sudo -u postgres initdb -E utf8 /Library/PostgreSQL8/data |
All new databases, from that point on, will default to UTF-8.
The above step has already been attended to in the forthcoming version 8.3 of the PG4Mac package. Kudos, Dru.
If You Get an Error About Shared Memory
In OS X 10.3.9 and later, create a file named /etc/sysctl.conf, containing these variable assignments, and reboot:
1 2 3 4 5 |
kern.sysv.shmmax=4194304 kern.sysv.shmmin=1 kern.sysv.shmmni=32 kern.sysv.shmseg=8 kern.sysv.shmall=1024 |
Install pgAdmin
If this is a workstation install, I would install pgAdmin as well.
Install PostgreS Gem
Finally, if you plan to connect Rails apps to PostgreSQL data, you will need to install the PostgreS Gem:
# gem install postgres -- --with-pgsql-dir=/Library/PostgreSQL8 |
Posted by rbrooks Filed in PostgreSQL
39 Comments
Dru Satori
November 9th, 2007 at 10:54 AM
Beware, as of PG 8.2, just setting the default to UTF8 isn’t enough, since initdb also accounts for the OS Locale to determine if the locale is a UTF8 locale. This will cure pgAdmin of it’s grumbles, but you may get some unexpected results in sorts.
Russ Brooks
November 25th, 2007 at 03:47 PM
Thanks, Dru. Good point.
When the “locale” parameter is omitted from
initdb,initdbautomatically applies the locale from the execution environment (the OS). If your system is already set to use a UTF-8 locale, theninitdbwill apply that locale to your PostgreS instance, and you won’t have sorting (“collation”) issues. I can only speak for Leopard set on “US English”, and it does use UTF-8 locale parameters across the board by default. I’d imagine that the last several OS X releases also came set to UTF-8 by default, because it has been the standard on most OSes released in the last 7 or 8 years. So, 99% of the readers reading this will not have any sorting problems when omitting the locale parameter frominitdb.To verify that your system is set with UTF-8 locale parameters, use the
localecommand from Terminal:If you see a
UTF-8in theLC_COLLATEparameter, then you will not have any sorting problems with your PostgreSQL data.If you do not see a
UTF-8value for theLC_COLLATEparameter, then you should reinitialize the database and include the--localeparameter with a valid UTF-8 locale for your system.To see the list of valid locales in your system, run
localewith an-aparameter (which means “all”):A long list will appear. Find the appropriate UTF-8 locale for your system and reinitialize the DB with that locale. For example, in New Zealand:
You may want to also verify that
initidbput the correct values into postgresql.conf.Find the following lines and verify that they all say “UTF-8”. If they do not, don’t edit them directly. Use
initidbto reinitialize the database with the correct ones.Daniel Lyons
November 25th, 2007 at 04:27 PM
The main reason I use MacPorts for PostgreSQL is to avoid having to keep track of what is out of date on my Mac. Having everything I installed via MacPorts off in /opt/local is inconvenient, but at least I don’t have to go and check to make sure my stuff is up to date.
On the other hand, some of my unpopular software (GHC) is perennially out of date in the MacPorts system. They’ve been pretty good about keeping PostgreSQL up to date though.
Jeffrey Gelens
November 25th, 2007 at 10:53 PM
Like Daniel said, a lot of people want to use a handy package manager like Macports or Fink to manage all installed software. One of the reasons can be that updates can be done easily. Another reason is that you can bulk install a lot of packages at the same time including the dependencies, that is impossible using standalone packages.
Dru_Satori
November 26th, 2007 at 10:08 AM
There is no question that MacPorts makes it ‘relatively’ easy to stay current. This is in fact one of the things that we are working on for the PostgreSQL for Mac project, a way to make it easy to keep current for the non-commandline users. Ports has a couple of GUI interfaces, but ultimately, they are still driving command line interfaces and if there is a problem, the user still has to drop to the command line to address them.
So, while not formally announced, what we are working on is implementing a Software Update like update system where a running system can check for updates and install them as needed. Long term, this should provide a reasonable alternative to the command line, and those who really prefer not to deal with the /opt/local/ or /sw/local trees.
Jeffrey Gelens
November 29th, 2007 at 07:08 PM
So in short, the difference is the “target audience”.
Dru Satori
November 30th, 2007 at 10:19 AM
Oh, absolutely Target Audience. Part of the reason PostgreSQL for Mac exists is that there is a large based of Mac Users and Developers that have no comfort level with the command line, and a still larger number that want or need a database engine, but don’t want or need the developer tools (Xocde, GCC etc) installed. For those people Ports and Fink are not viable options. So, there is Marc Liyange’s excellent installer, which uses the /opt/local tree, and then there is PG for Mac which tries to “Macify” things into the /Library/PostgreSQL8 tree, as well as provide soem GUI tools to make it easier and more approachable to the users for whom, bash is something comic book characters do to bad guys, and psql is what you do after a late night of binge drinking and database management :-).
Patrick
December 8th, 2007 at 03:21 AM
So please forgive the stupid question, but I got everything installed however I can’t get postgres started. Do I need to be the postgres user to start the database? what is the password? Thanks.
Russ Brooks
December 9th, 2007 at 03:02 PM
You should be able to change the “postgres” user password from the OS X GUI. System Preferences > Accounts. I changed mine and everything still works. PG4Mac created the appropriate boot scripts so that PostgreS starts on boot. If you need to manually start it, try using the PostgreS “Service Manager” applet that was installed by PG4Mac [into your Applications folder]. There is a checkbox to “Auto-start service at boot”.
Turi
December 13th, 2007 at 07:32 AM
Hi, your solution worked fine, but I experienced an authorization error that prevented the creation of the new database by user postgres. I solved it this way: sudo mkdir /Library/PostgreSQL8/data sudo chown postgres:postgres /Library/PostgreSQL8/data
and finally
sudo -u postgres initdb -E utf8 /Library/PostgreSQL8/data
Bart Busschots
December 19th, 2007 at 03:48 PM
Thanks for these instructions. They are most helpful, however, I’ve run into a bizarre snag. I THINK I followed all your instructions but when I try to create a user or a DB I get the following mad error:
createuser bart Shall the new role be a superuser? (y/n) y createuser: could not connect to database postgres: FATAL: role “252F6238093003CC96A19B829010327D1B3019B8” does not exist bash-3.2$ whoami postgres bash-3.2$
As you can see from the result of whoami I was trying that as the postgres user. I got to the postgres user with the command: sudo -u postgres bash. This is not how I’d normally do it but my normal way doesn’t work with this postgres install for some reason. I’d normally do: sudo su - postgres but when I do that I don’t get to be postgres. I get back to my own account … not sure how.
Has anyone seen this problem before? And more importantly, does anyone have a solution?
Thanks,
Bart.
dru
December 20th, 2007 at 09:59 AM
No, that should work fine (that’s how I work on the command line).
When you you sudo postgres, do you not get an error?
What I would look for is, did the user get created? You can check this from the command line using the following:
/usr/bin/dscl . -read /users/postgres | grep “^UniqueID:.[0-9]” | sed ‘s/.*: //’ | sed ‘s/ //’
This will return an ID if it’s found, if not, you’ll get:
<dscl_cmd> DS Error: -14136 (eDSRecordNotFound)
If that returns an ID, then the user itself is setup, but the configuration may be wrong, though how, I’m not certain, the script that sets up the user looks like this:
where $PGUID and $PGGID are both chosen by finding the first unassigned ID’s in the 400 range.
If you want to work through this in more detail, come hunt me down, I’m the primary author of the package. http://www.druware.com or http://www.postgresqlformac.com.
Kevin Allen
December 27th, 2007 at 12:17 AM
Just curious why was the UserShell set to /usr/bin/false ? This is why su - postgres will fail as there is no shell. Also why was home dir set to /var/empty.
Thanks!
Kevin
Dru
December 27th, 2007 at 09:57 AM
Kevin,
Both settings are to prevent the Postgres user from display on the Login screen as interactive users (as is the use of a 400 series group and user id).
When I need to work as the postgres user, I general sudo bash; su postgres
Michael
December 31st, 2007 at 02:13 PM
I just tried this and everything worked perfectly - except for the gem installation. I’ve tried this now using a number of different techniques - all with the same result:
$ sudo gem install postgres – –with-pgsql-dir=/Library/PostgreSQL8/ Building native extensions. This could take a while… ERROR: While executing gem … (Gem::Installer::ExtensionBuildError) ERROR: Failed to build gem native extension.
ruby extconf.rb install postgres – –with-pgsql-dir=/Library/PostgreSQL8/ checking for main() in -lpq… no * extconf.rb failed * Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.
Provided configuration options: –with-opt-dir –without-opt-dir –with-opt-include –without-opt-include=${opt-dir}/include –with-opt-lib –without-opt-lib=${opt-dir}/lib –with-make-prog –without-make-prog –srcdir=. –curdir –ruby=/usr/local/bin/ruby –with-pgsql-dir –with-pgsql-include –without-pgsql-include=${pgsql-dir}/include –with-pgsql-lib –without-pgsql-lib=${pgsql-dir}/lib –with-pqlib –without-pqlib Could not find PostgreSQL build environment (libraries & headers): Makefile not created
Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/postgres-0.7.9.2007.12.22 for inspection. Results logged to /usr/local/lib/ruby/gems/1.8/gems/postgres-0.7.9.2007.12.22/ext/gem_make.out
——————————–
Any ideas? I’ve also tried unzipping the Developer package and entering the command like:
sudo gem install postgres – –with-pgsql-include=/opt/local/include –with-pgsql-lib=/opt/local/lib
Josh Kim
December 31st, 2007 at 09:51 PM
Thank you so much! The entire Rails/Leopard/PostgreSQL was driving me nuts until I came upon this lovely post. Definitely cleared up a lot of things for me.
Michael
January 1st, 2008 at 10:31 PM
Just a quick update to let you know I’ve solved my earlier problem. The issue was that I hadn’t bothered to update my Developer Tools when I installed Leopard so I was getting some strange errors which I couldn’t find anywhere else.
I discovered this by trying to compile GEOS and getting a bizarre error about the version of gcc I was using. Xcode also crashed on startup.
Once I installed XCode 3.0, everything worked perfectly. Thanks again for a great post.
Mike DeVuyst
January 1st, 2008 at 11:53 PM
I cannot get the service started. When I try to create a new DB. I get this Error: createdb: could not connect to database postgres: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket “/tmp/.s.PGSQL.5432”?
When I go into the service manager I hit start, and it asks to authenticate and I do(as the only OS user), but it dose not change the status.
Mike DeVuyst
January 2nd, 2008 at 12:07 AM
Found my problem/answer here, http://sourceforge.net/forum/forum.php?threadid=1271905&forumid=451648
lanaer
January 3rd, 2008 at 05:15 PM
@Michael
Check ext/mkmf.log in the postgres gem directory. If it has a line like “gcc-4.0: Invalid arch name : Power”
I had a similar problem with the dopostgresql gem, which seemed to be because ENV[“RCARCHS”] was being set incorrectly in ext/extconf.rb. However, I haven’t had this problem with the postgres gem, so I’m not sure if it’s the same thing.
Mark Bee
January 5th, 2008 at 11:09 PM
Hi,
I can’t seem to get anything working. It looks as if a “postgres” user was created but it doesn’t show up in System Preferences, and when I try “su postgres” and type the password “postgres” it says “su: Sorry” and I can’t do anything.
I’m stumped. I never had any of these problems under Tiger…
Dru
January 6th, 2008 at 12:34 AM
Try doing ‘sudo bash’, however, I’ll honestly say that I so rarely run ANYTHING as postgres in the shell.
AG
January 19th, 2008 at 12:51 PM
Good to find this tutorial. I was having trouble with the step: $ sudo -u postgres initdb -E utf8 /Library/PostgreSQL8/data
I ran the command: sudo passwd root
Set a new password and it worked from there.
Henrik
January 25th, 2008 at 06:52 PM
Novice query: I’m in desperate need of some (simple) advice on databases and have been unable to get ANY help here at my university or (so far) on the net, where there is an enormous amount of information for everyone who knows what they’re doing. In short, I’m a research ecologist and have now accumulated a lot of data, most of which is in Excel files and notebooks (the paper kind). Two years ago I started learning and using MS-Access and VBA, creating a few simple, straight forward backend tables and some frontend forms on my office computer. We don’t have the money to hire a database manager, so I’m it, and now I have to make the database such that different students can enter data (on this one computer), with the long-term aim (1-2 years) of putting the database on a server, so that 4 or 5 students can enter data remotely and at the same time (and, if all goes well, making the data easily available to colleagues). So, I’ve been told MySQL or PostgreSQL is the way to go, and using something called ‘Ruby’ as a frontend. Is this good advice? If so, can one use, say PostgreSQL and Ruby on a single computer (I use a MacBook Pro running Leopard), without initially having them on a server or being connected to any network (completely standalone)? And do I need any other program(s) to create the sort of frontend forms that MS-Access has? Any help would be greatly appreciated.
dru_satori
January 26th, 2008 at 12:48 PM
Not only can you, this is an ideal use of the tools, and yes, you can run them all on a single computer. However, this is a toolchain best suited to *nix (Linux, FreeBSD, Solaris, Mac OS X, etc) platforms and really isn’t well suited to Windows.
Now, since you already have an Access database (which honestly would terrify me considering Access’s ability to lose data), you’ll need to migrate that data, and that will play into your process, but most of your decisions needs to be based upon how you are going to serve the application.
You’ve got alot of options, but before you can really pick a direction, you need to make those choices.
Personally, I’d be thinking web application for entry & reporting. It’s the easiest to create and deploy. If that’s the route, then the choice of platform becomes crucial. If you deploy to Windows, your only real answer is ASP.NET and a database, which could be Access, PostgreSQL, MySQL or MSSQL (I’m partial to PostgreSQL for price/performance). If you go Linux or Mac, then Ruby on Rails with PostgreSQL is a powerful pair of tools that is relatively easy to deploy.
Good luck, and if you have questions…
Henrik
January 26th, 2008 at 05:35 PM
Finally! Some advice I understand. Thank you!! Now I really have to hurry with changing backends, because I think Access HAS lost data or at least corrupted records. Ok, it’ll be Mac in the short term (possibly Linux in the long run, but less likely). Given your comments, PostgreSQL for the backend and Ruby on Rails for the frontend would seem a good choice. So, the next question: what is the ‘recommended’ method of putting these programs on a Mac? Russ’s comments above suggest one way, while others, as he says, prefer using ‘MacPorts’. Being a novice, I wouldn’t have a clue how to judge these options, but I’m not fussed about method, unless one of them is more likely to ensure that the programs work better. And does one need any other software besides these two?
Russ Brooks
February 10th, 2008 at 09:49 PM
To add to Dru’s point about MS Access. An Access database should never be connected to a website in any way, even very simple sites - or any multiuser applications really - despite the fact the it will let you do these things. Access was never designed to be a multiuser database. It does not have the robust locking and concurrency-control mechanisms that SQL databases have. I can only speak from first-hand experience with Access XP & ‘03 [I am ashamed to admit], but Access does a database-level lock when anyone writes data. This is outrageously inefficient. Picture your entire website suddenly throwing errors for all users because someone else simply saved a form. Sometimes the lock would never free up, rendering the site completely down. You would have to manually delete the lock file [.ldb] in the same folder as the DB and the database would unlock.
Some quick Googling will reveal some others experiencing the same issues.
It appears that Access 2007 still has this lock file, but with a different extension [.laccdb]. I would stay away from Access in a multi-user environment. If you are going the Microsoft route and want a simple, free solution that *is* conducive to the Web, then SQL Express is the way to go. The robustness of SQL Server without the price tag.
In the F/OSS world, PostgreSQL, in my opinion, is the only choice. MySQL is enticing in that is has some slick GUI-based tools that come along with it, but don’t be dazzled by the fluff. MySQL has some serious scalability issues with multi-core CPU’s. MySQL performance increases only 36% when going from 1 to 4 cores. PostgreS performance increases 226%. This will be a major factor as we watch the cores in our processors quadruple, octuple, and decuple over the next few years. [It remains to be seen if Sun, having recently acquired MySQL, will tidy up these issues.] There are dozens of other reasons why MySQL doesn’t compare to PostgreSQL, from the storage engine, to locking mechanisms, to ACID-compliance, to standards-compliance, to function-language support, to stability, but I won’t get into the details because there are plenty online.
As far as a WYSIWYG forms designer, there is a list of PostgreSQL GUI tools on the postgres.org site. I haven’t used them personally, aside from using pgAdmin III pretty much on a daily basis. pgAdmin isn’t a form designer, though, but more an administration and querying tool].
There are even some Access-to-PostgreSQL conversion tools on that site. Scroll down.
Dewight
February 12th, 2008 at 06:43 PM
So I have a G4 powerbook with Tiger and was able to get postgres running, with help from another site. This site looked promising for my Office G5 Lepord , but I have spent two days now trying to get postgres working and it seem to be fighting me the entire way.(or I am fighting it)
It seems like permission errors, and after 3 hours of trying different things I asked for help from a postgres person here and they tryed for about half an hour and said they dont know and left.
So, now I made myself the owner of the postgres files and still not able to start the db.
” LOG: could not bind IPv6 socket: Address already in use HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry. LOG: database system was shut down at 2008-02-12 15:37:40 PST LOG: checkpoint record is at 0/42BF48 LOG: redo record is at 0/42BF48; undo record is at 0/0; shutdown TRUE LOG: next transaction ID: 0/594; next OID: 10820 LOG: next MultiXactId: 1; next MultiXactOffset: 0 LOG: database system is ready ”
” $ createdb test FATAL: role “dfkramer” does not exist createdb: could not connect to database postgres: FATAL: role “dfkramer” does not exist ”
dru_
February 13th, 2008 at 10:09 AM
Judging by the two logs, I would suspect that you have two copies of the DB running on that machine.
Olga
March 6th, 2008 at 06:10 PM
Thank you for these detailed explanations! Everything is written very clear, even for me, new with these mac/unix things…
But never the less I didn’t succeed to pass all the installation guide up to the end: when I’m trying to execute “sudo -u postgres initdb -E utf8 /Library/PostgreSQL8/data” command this is what I get in the terminal window:
78-106-78-117:PostgreSQL8 olgaryzikova$ sudo -u postgres initdb -E utf8 /Library/PostgreSQL8/data The files belonging to this database system will be owned by user “postgres”. This user must also own the server process.
The database cluster will be initialized with locale ru_RU.UTF-8. The default text search configuration will be set to “russian”.
fixing permissions on existing directory /Library/PostgreSQL8/data … initdb: could not change permissions of directory “/Library/PostgreSQL8/data”: Operation not permitted
I saw in the discussions that other people also faced similar problem and I tried to used approaches proposed by Turi and AG, but it didn’t help… :(
May be somebody has the same situation as me? Any help is VERY appreciated!
Olga
March 8th, 2008 at 04:11 PM
I just wanted to say that I’ve solved the problem described in my previous post. What I did is:
May be it will be useful for somebody. Thanks!
schande
March 18th, 2008 at 08:03 PM
this is what i’m getting after the install:
tisseenG5:~ root# sudo /Library/StartupItems/PostgreSQL/PostgreSQL start Starting PostgreSQL database server shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied could not identify current directory: Permission denied could not identify current directory: Permission denied could not identify current directory: Permission denied The program “postgres” is needed by pg_ctl but was not found in the same directory as “pg_ctl”. Check your installation.
Dan Coyle
March 18th, 2008 at 08:30 PM
I’m wondering if someone can help me. First of all, I’m very grateful to the talented folks that make cool things like this available. Second, I’m a complete newbie at most of this, so pardon my ignorance of some things.
Dru’s install works wonderfully. I’m not sure what I did right, but the first install didn’t quite work. I enabled root and ran the installer again and Service Manager reported that all was well. pgAdmin3 also works great.
What I’d like to do is get PHP to work with PGSQL without re-installing PHP over Apple’s install. I found this site, http://www.heritage-tech.net/165/getting-additional-php-modules-without-totally-recompiling/, just Googling around, where a Linux guru was able to compile the dynamic library, pgsql.so, that can be loaded dynamically when PHP starts. I followed instructions, changing the path in the instructions to point to where PGSQL was installed. I ended up with a pgsql.so library, but unfortunately it doesn’t seem to want to load. I tried both the 5.2.4 and 5.2.5 source (although it now looks like the Safari 3.1 upgrade has upgraded PHP to 5.2.5), but the extension won’t load. I changed extension_dir in php.ini to explicitly point to the library, but no luck.
Is there someone knowledgeable (!=me) that can point me in the right direction or ideally provide a binary that would work?
Again, thanks for all the work.
Doug Kuyvenhoven
March 21st, 2008 at 07:14 PM
Hi Dru:
Back on Dec 27th you mentioned to Kevin Allen “Both settings are to prevent the Postgres user from display on the Login screen as interactive users (as is the use of a 400 series group and user id).” in response to his comment:
“Just curious why was the UserShell set to /usr/bin/false ? This is why su - postgres will fail as there is no shell. Also why was home dir set to /var/empty”
I would like to be able to keep the postgres user ‘visible’ and be able to ‘su - postgres’ and get to the shell and have a home directory.
Are there some command line commands I can execute to set the ‘postgres’ UserShell and home dir so that I can ‘su - postgres’?
schande
March 22nd, 2008 at 07:12 PM
i fixed my earlier stated problem with
su -m postgres -c ‘/Library/PostgreSQL8/bin/pg_ctl start -D /Library/PostgreSQL8/data -l /Library/PostgreSQL8/log/PostgreSQL8.log -o -i’
Andrew Hodgkinson
March 23rd, 2008 at 09:14 AM
Some trouble here may be caused by the newer PostgreSQL 8.3.0 installation. The article’s recommended procedure works fine with the 8.2.* release. The postgresqlformac.com created a ‘postgres’ user. The /Library/PostgreSQL8 folder is owned by this user, so the initdb command works as expected. In the 8.3.0 installer recently released, things do not work so well. You can follow some of the bugs and updates from the news page:
http://www.postgresqlformac.com/news/
I have two machines. One has the 8.2.5 release, with ‘postgres’ owning things all over the place. The other just had a fresh 8.3.0 installation done. There is no sign of the ‘postgres’ user at all. Everything is owned by my login user, with the exception of the log folder in /Library/PostgreSQL8, owned by root. This is an installer bug, listed in the news page linked to above. If you’ve got the proper ‘postgres’ user ownerships, you can fix it with:
sudo chown -R postgres:admin /Library/PostgreSQL8/log
In my case nothing is owned by this user anyway, it’s all under my login account, so I change ‘postgres’ to my user name instead. Same goes for anywhere else you might see ‘postgres’.
The 8.3.0 release sets the owner of /Library/PostgreSQL8 to ‘root’. If you run the database with its preset contents, this is probably a good security measure. But since we’re going to change the contents, you need to get the initdb command to work; for that, you need to give yourself, or the ‘postgres’ user - whichever is appropriate - permission to alter the contents of /Library/PostgreSQL8:
sudo chown <username> /Library/PostgreSQL8
Then you should be able to run the initdb line. You may wish to restore permissions on the PostgreSQL8 folder to ‘root’ afterwards, assuming it’s a valid thing to prevent even the database itself from altering anything immediately inside the folder.
I see from the news page that the 8.3.1 installer is imminently due. Given the problems, you may wish to hold off installing 8.3.0 and wait.
Giovanni
April 22nd, 2008 at 06:52 PM
I want to answer to Dan Coyle (topic of March 18th, 2008 at 08:30 PM)
I’ve used the link posted http://www.heritage-tech.net/165/getting-additional-php-modules-without-totally-recompiling/ and I’ve resolved!!!
There are few modify to do: 1- Use php 5.2.5 (or the same you have in this moment) 2- use the command “./configure –with-pgsql=shared,/Library/PostgreSQL8/” and not the one indicated in that web page, because the Postgres install directory is the one I’ve written 3- in php.ini file change the line extensiondir = “./” with extensiondir = “/usr/lib/php/extensions/” 4- Compile php with make 5- Copy pgsql.so in /usr/lib/php/extensions/ 6- restart apache
In this way it works perfectly
(sorry for my bad english) Giovanni
Sam Hunting
April 29th, 2008 at 12:06 AM
My 8.3.1 install went fine, except that no postgres user was created (and I had deleted my previous postgres user). What would be really useful to have for plan B, in the documentation, would be:
The niload commands to create the user and group
The owners/groups of the PostGres directory structure
How to start from the command line (and with which user!)
Thanks for a wonderful package. So nice not to have to fiddle with gcc_version, etc.
Ronald Hulen
May 4th, 2008 at 10:21 AM
The 8.3.1 MacPort works well on my macbook and the client tools are awesome. I cannot seem to create a database cluster on an external HFS+ formatted disk. Even when the file structure on the disk is owned by postgres.
The install dies at: creating template1 database in /Volumes/ExternalHardDrive/PostgresData/base/1 … FATAL: could not create shared memory segment: Cannot allocate memory
DETAIL: Failed system call was shmget(key=1, size=1982464, 03600).
I can create the database cluster on the local macbook disk fine, but I am running out of space FAST!
BTW, I added the sysctl.conf file to etc with the parameters kern.sysv.shmmax=4194304 kern.sysv.shmmin=1 kern.sysv.shmmni=32 kern.sysv.shmseg=8 kern.sysv.shmall=1024
but I still get the same error.
Any ideas?
Posting Info: Markdown and SmartyPants are supported for formatting and punctuation respectively. Your email address will never be published. Your name will link to your website address, if entered. Inappropriate comments will be edited or deleted.