Sunday, January 29, 2012

Re: confusion about choosing the database user name (Postgresql/psycopg2)

You should not use www-data as your user. There is little reason for
allowing any access to the database for www-data user. The user in
settings.py refers to PostgreSQL user. You should set up a dedicated
postgresql user, and a password for that user. Use those in your
settings.py.

The most likely reason for the error you got is that you have a line
like this in your pg_hba.conf (the file is located under /etc/
postgresql/ when using Ubuntu / Mint):
local all all peer

Add a line like this _above_ the local-all-all line:
local all theuser md5
where theuser is of course the database user. Be sure that you can
revert your changes to that file if need be. Postgresql will not start
again if that file is corrupt.

Restart postgresql and hope for best. If the above doesn't work,
google for pg_hba.conf. pg_hba.conf is probably the hardest thing you
ever need to learn about postgresql. It can be a little confusing at
times... :)

- Anssi

On Jan 23, 6:48 pm, MiddleForkGIS <middlefork...@gmail.com> wrote:
> I'm a little confused about the choice of the database user to specify
> in the settings.py configuration file.
>
> On the one hand, if I set the user to be 'www-data' (the Apache2
> user), I can serve pages to the public just fine, but cannot use the
> admin site.
>
> DatabaseError at /admin/
> permission denied for relation django_session
>
> Which of course is desirable, because user 'www-data' should have read-
> only access to the tables
>
> ------
>
> Conversely, if I set the user to be a real user (ie "myself") then I
> can utilize the admin site but cannot serve pages to the public.
>
> File "/usr/lib/python2.7/dist-packages/django/db/backends/
> postgresql_psycopg2/base.py", line 140, in _cursor
>
> self.connection = Database.connect(**conn_params)
> OperationalError: FATAL:  Peer authentication failed for user "myself"
>
> -----
>
> What am I failing to do or to understand?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment