Postgres installation on Leopard; database on Mac-User-Level

Started by Stefan Schwarzerabout 18 years ago4 messagesgeneral
Jump to latest
#1Stefan Schwarzer
stefan.schwarzer@grid.unep.ch

Hi there,

I want to create my database not under /etc/.... but under or within
my Mac-user level, that is /Users/schwarzer/....

Now, it seems somewhat complicated - at least for me -, due to the
different read-write permissions, to do that. It worked before, but
now, after re-installing the machine, I really don't get it going...

The commands would be like this:

/usr/local/pgsql/bin/initdb -D /Users/schwarzer/Documents/data_postgres
/usr/local/pgsql/bin/postmaster -D /Users/schwarzer/Documents/
data_postgres >logfile 2>&1 &

But, what about the user "schwarzer" and the user "postgres"? How
should it correctly be installed/configured?

Thanks for any advice,

Stef

#2Richard Huxton
dev@archonet.com
In reply to: Stefan Schwarzer (#1)
Re: Postgres installation on Leopard; database on Mac-User-Level

Stefan Schwarzer wrote:

Hi there,

I want to create my database not under /etc/.... but under or within my
Mac-user level, that is /Users/schwarzer/....

The data directory shouldn't ever end up in /etc - are you sure that's
what it's doing?

Now, it seems somewhat complicated - at least for me -, due to the
different read-write permissions, to do that. It worked before, but now,
after re-installing the machine, I really don't get it going...

The commands would be like this:

/usr/local/pgsql/bin/initdb -D /Users/schwarzer/Documents/data_postgres
/usr/local/pgsql/bin/postmaster -D
/Users/schwarzer/Documents/data_postgres >logfile 2>&1 &

But, what about the user "schwarzer" and the user "postgres"? How should
it correctly be installed/configured?

Well, the main thing to remember is that the database server needs to
have read+write access to the data directory (and log directory) but
no-one else needs to. So:
cd /Users/schwarzer/Documents
chown postgres:postgres data_postgres
chmod 0700 data_postgres
(you might also need to check that PG can cd to each directory in the
path too:)
chmod a+x /Users/schwarzer/Documents
chmod a+x /Users/schwarzer

There's no reason why you *have* to run the server as user postgres
though. It's perfectly possible to do the above as user schwarzer. If
the database system is intended just for that one user, that might make
sense too.

Oh, make sure the logfile is in a directory writable by the same user
too of course.

--
Richard Huxton
Archonet Ltd

#3Stefan Schwarzer
stefan.schwarzer@grid.unep.ch
In reply to: Richard Huxton (#2)
Re: Postgres installation on Leopard; database on Mac-User-Level

Now, it seems somewhat complicated - at least for me -, due to the
different read-write permissions, to do that. It worked before, but
now, after re-installing the machine, I really don't get it going...
The commands would be like this:
/usr/local/pgsql/bin/initdb -D /Users/schwarzer/Documents/
data_postgres
/usr/local/pgsql/bin/postmaster -D /Users/schwarzer/Documents/
data_postgres >logfile 2>&1 &
But, what about the user "schwarzer" and the user "postgres"? How
should it correctly be installed/configured?

Well, the main thing to remember is that the database server needs
to have read+write access to the data directory (and log directory)
but no-one else needs to. So:
cd /Users/schwarzer/Documents
chown postgres:postgres data_postgres
chmod 0700 data_postgres
(you might also need to check that PG can cd to each directory in
the path too:)
chmod a+x /Users/schwarzer/Documents
chmod a+x /Users/schwarzer

There's no reason why you *have* to run the server as user postgres
though. It's perfectly possible to do the above as user schwarzer.
If the database system is intended just for that one user, that
might make sense too.

Oh, make sure the logfile is in a directory writable by the same
user too of course.

You guys are too kind. Really. A big THANK YOU for everybody helping
me (and others) to get things working! You really do a fantastic job!

So, when you say that there is no reason to be obliged to run the
server as user postgres, but that I can run it as user schwarzer: then
I can skip the chown/chmod steps you mentioned? I just go for the
initdb etc. commands as listed above, without specifying a(nother) user?

#4Richard Huxton
dev@archonet.com
In reply to: Stefan Schwarzer (#3)
Re: Postgres installation on Leopard; database on Mac-User-Level

Stefan Schwarzer wrote:

There's no reason why you *have* to run the server as user postgres
though. It's perfectly possible to do the above as user schwarzer. If
the database system is intended just for that one user, that might
make sense too.

Oh, make sure the logfile is in a directory writable by the same user
too of course.

You guys are too kind. Really. A big THANK YOU for everybody helping me
(and others) to get things working! You really do a fantastic job!

People helped us when we started here. Hopefully you'll feel the same :-)

So, when you say that there is no reason to be obliged to run the server
as user postgres, but that I can run it as user schwarzer: then I can
skip the chown/chmod steps you mentioned? I just go for the initdb etc.
commands as listed above, without specifying a(nother) user?

Exactly.

You might have to chmod 0700 on the data directory though, PG might well
complain if other users have access.

Oh, and be careful if you are running as yourself - that means you can
delete/mangle the data files from the browser etc.

--
Richard Huxton
Archonet Ltd