Rails中的PostqreSQL:如何使服务器在本地运行并接受Unix域套接字上的连接? [英] PostqreSQL in Rails: How do I make the server run locally AND accept connections on the Unix domain socket?

查看:496
本文介绍了Rails中的PostqreSQL:如何使服务器在本地运行并接受Unix域套接字上的连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我是Rails的新手,他们之前只使用过SQLite3,而且在使用PostgreSQL时,我甚至努力运行一个简单的rake命令。



m只是试图在安装Postgres之后关注此屏幕录像的前5分钟: http:// railscasts.com/episodes/342-migrating-to-postgresql



但即使我按照指示完成了所有工作,当我运行 rake db:create:all 我得到无处不在的错误信息:

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

我到处都可以看到这个,但是有人可以一劳永逸地回答这个问题(如果这样的任务)

我使用自制软件安装PostgreSQL。



当我运行 which which psql ,它表示我使用 usr / bin / psql 中的一个,我相信它是Mac原生的那个OSX Lion(这不是一件坏事吗?我如何切换到由homebrew安装的,位于 usr / local / bin / psql ?)。 p>

我相当确定Postgres至少在运行:当我运行 ps auxw | grep postgres ,我得到了我的四个进程,例如:

  postgres:stats收集器进程
postgres:autovacuum启动器进程
postgres:wal编写器进程
postgres:编写器进程

我甚至可以安装我的 pg gem。我花了整整一天的时间试图让Postgres运行,我非常感谢所有帮助!



编辑(有解决方案):

引用此链接:



升级到OSX 10.7 Lion后修复Postgresql



确实存在路径问题。所以我按照说明编辑了我的.bash_profile文件,并从使用我的本地psql安装( usr / bin / psql )切换到homebrew安装的版本, usr / local / bin / psql

然后,我卸载了我的pg gem,然后重新安装了它,然后rake dr:create:all开始工作。 :)

编辑2:



其实,我仍然有很多问题!这太令人沮丧了! :)

解决方案

您的权限可能已经搞乱了。尝试

  sudo chmod -R 777 / var / pgsql_socket / 
$ b $

这为每个人提供了开放权限,所以对于您的开发服务器需求来说很好。



现在应该可以工作了。

So I'm a newbie to Rails who's only used SQLite3 before, and I'm struggling to even run a simple rake command when using PostgreSQL.

I'm just trying to follow the first 5 minutes of this screencast on installing Postgres: http://railscasts.com/episodes/342-migrating-to-postgresql

But even when I've done everything as instructed, when I run rake db:create:all I get the ubiquitous error message:

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 see this everywhere, but can someone answer this definitively, once and for all (if such a task were so simple)?

I used homebrew to install PostgreSQL.

When I run which psql, it says i'm using the one in usr/bin/psql, which I believe is the one that is native to Mac OSX Lion (isn't that a bad thing? How do I switch to the one installed by homebrew, which is in usr/local/bin/psql?).

I'm fairly certain Postgres is at least running: when I run ps auxw | grep postgres, I get my four processes, such as:

postgres: stats collector process
postgres: autovacuum launcher process
postgres: wal writer process
postgres: writer process

And I was even able to install my pg gem just fine. I've been spending all day just trying to get Postgres to run, I appreciate any and all help!

EDIT (WITH SOLUTION):

Referencing this link:

Repairing Postgresql after upgrading to OSX 10.7 Lion

There was indeed a path issue. So I edited my .bash_profile as instructed, and switched from using my native psql installation in usr/bin/psql to the one installed by homebrew, usr/local/bin/psql.

Then, I uninstalled my pg gem, and then reinstalled it, and then rake dr:create:all started working. :)

EDIT 2:

Actually, I'm still having loads of problems! This is so frustrating! :)

解决方案

Your permissions are probably messed up. Try

sudo chmod -R 777 /var/pgsql_socket/

This gives open permissions to everyone, so it's fine for your development server needs.

Now it should work.

这篇关于Rails中的PostqreSQL:如何使服务器在本地运行并接受Unix域套接字上的连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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