运行Django的syncdb时出现Postgresql套接字错误(mac OS 10.7.5) [英] Postgresql socket error when running Django's syncdb (mac OS 10.7.5)

查看:101
本文介绍了运行Django的syncdb时出现Postgresql套接字错误(mac OS 10.7.5)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行Django的syncdb操作,并出现以下错误:

  psycopg2.OperationalError:无法连接到服务器:拒绝的权限
服务器是否在本地运行,并在Unix域套接字/var/pgsql_socket/.s.PGSQL.5432上接受
连接?

我已经阅读了此问题,并尝试过以下操作:




  • 将listen_address更改为/Library/PostgreSQL/9.1/data/potsgresql.conf中的localhost或*
  • 将主机更改为我的settings.py文件(用于Django)中的localhost
  • 用户在settings.py


中设置了具有正确密码的postgres p>(每个步骤后我重新启动了postgresql服务器。)



我还检查了我的pg_hba.conf文件,看Unix域套接字是否接受所有的连接用户(基于此页面)。这里是我在那里:

 #本地是针对Unix域套接字连接只有
本地所有md5
#IPv4本地连接:
主机全部127.0.0.1/32 md5
#IPv6本地连接:
主机全部:: 1/128 md5

我以前从来没有这个问题。我最近升级到了Lion,并且正在开发一个新的virtualenv,安装了最少的模块。

解决方案

找到答案礼貌的 Bradley Ayers




  • 将postgres.conf中的/ var / pgsql_socket /设置为unix_socket_directory
  • 执行以下命令:

    • $ sudo dscl。append / Groups / _postgres GroupMembership postgres
    • $ sudo chmod g + w,o + rx / var / pgsql_socket /

  • 重新启动postgresql

I'm trying to run Django's syncdb operation and am getting the following error:

psycopg2.OperationalError: could not connect to server: Permission denied
    Is the server running locally and accepting
    connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?

I've read the answers to this question and have tried the following:

  • changing "listen_address" to "localhost" or "*" in /Library/PostgreSQL/9.1/data/potsgresql.conf
  • changing "host" to "localhost" in my settings.py file (for Django)
  • user is set to "postgres" with correct password in settings.py

(I restarted the postgresql server after each step.)

I've also checked my pg_hba.conf file to see if the Unix domain socket was accepting connections from all users (based on this page). Here's what I have there:

# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5

I never had this problem before. I somewhat recently upgraded to Lion and am working on a new virtualenv with the bare minimum of modules installed.

解决方案

Found the answer courtesy of Bradley Ayers:

  • set "unix_socket_directory" to "/var/pgsql_socket/" in postgres.conf
  • executed following commands:
    • "$ sudo dscl . append /Groups/_postgres GroupMembership postgres"
    • "$ sudo chmod g+w,o+rx /var/pgsql_socket/"
  • restarted postgresql

这篇关于运行Django的syncdb时出现Postgresql套接字错误(mac OS 10.7.5)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆