0

我正在尝试运行 Django 的 syncdb 操作并收到以下错误:

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"?

我已阅读此问题的答案并尝试了以下方法:

  • 在 /Library/PostgreSQL/9.1/data/potsgresql.conf 中将“listen_address”更改为“localhost”或“*”
  • 在我的 settings.py 文件中将“主机”更改为“本地主机”(对于 Django)
  • 用户在 settings.py 中设置为“postgres”,密码正确

(我在每一步之后都重新启动了 postgresql 服务器。)

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

# "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

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

4

2 回答 2

1

找到了Bradley Ayers提供的答案:

  • 在 postgres.conf 中将“unix_socket_directory”设置为“/var/pgsql_socket/”
  • 执行以下命令:
    • “$ sudo dscl。附加 /Groups/_postgres GroupMembership postgres”
    • "$ sudo chmod g+w,o+rx /var/pgsql_socket/"
  • 重新启动postgresql
于 2012-10-30T02:59:22.153 回答
0

你的数据库没有运行试试

pg_ctl -D /usr/local/var/postgres 启动

假设那是您的 postgre 数据目录所在的位置

于 2012-10-29T05:43:24.007 回答