简体   繁体   English

从Navicat或Induction连接到本地Postgres.app时出错

[英]Errors when connecting to local Postgres.app from Navicat or Induction

Ok, so I have Postgres.app on my mac. 好的,所以我的Mac上有Postgres.app。

It's running locally insofar as I know. 据我所知,它在本地运行。 (the little elephant icon in top bar) (顶部栏中的小象图标)

Created a very basic rails application, and it worked fine, ie, it showed up in browser. 创建了一个非常基本的Rails应用程序,并且运行良好,即显示在浏览器中。

Trying to connect it to Navicat Lite http://www.navicat.com/ . 尝试将其连接到Navicat Lite http://www.navicat.com/ It keeps coming up with this error: FATAL: role "postgres" does not exist. 它不断出现以下错误: FATAL: role "postgres" does not exist.

Can't quite figure out how to solve this, so I happened to come across Induction http://inductionapp.com/ and tried to use it to connect to Postgres again, and this is the error it comes up with: 无法完全弄清楚如何解决此问题,因此我碰巧遇到了Induction http://inductionapp.com/,并试图再次使用它来连接到Postgres,这是它​​带来的错误:

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

Not really sure how to solve this. 不太确定如何解决此问题。

Have googled around on this, and some of the fixes seemed a little complicated, and right now, don't want to do fixes that I can't quite understand nor rollback. 谷歌搜索,一些修复似乎有点复杂,现在,不想做我不太了解或回滚的修复。

Halp? HALP?

EDIT (including my bash info) 编辑 (包括我的bash信息)

export PGHOST=localhost
PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
export PATH=/usr/local/bin:$PATH
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting

### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"

EDIT TWO 编辑两个

Ok, not sure how this happened of sorts. 好的,不确定这是怎么发生的。

Was randomly running Navicat again (sort of like a mouse in a running wheel?), and changed a few of the data entered on 'Connection Properties' page, ie, username and password - set it to what my laptop's info is. 是否又再次随机运行Navicat(就像在运行中的鼠标一样?),并更改了在“连接属性”页面上输入的一些数据,即用户名和密码-将其设置为笔记本电脑的信息即可。

It worked. 有效。

So, yay? 所以,是吗?

But then when I tried it with Induction, got the same error as listed in this post. 但是,当我在Induction上尝试使用它时,出现了与本文中列出的错误相同的错误。

So, not sure what's going on, and why simply it works for Navicat and not Induction? 因此,不确定发生了什么,为什么它仅适用于Navicat而不适用于Induction?

EDIT THREE 编辑三

Hm ... ok, just tried Induction again, and actually typed localhost this time instead of leaving it to their default of 127.0.0.0 ... and it worked! 嗯...好吧,再次尝试了归纳法,这次实际上输入了localhost而不是将其保留为默认值127.0.0.0 ...,它起作用了!

Hm, is this good news? 嗯,这是个好消息吗?

Also, the results of 'which psql' is this: /usr/bin/psql which doesn't seem right to me, given what I've put in my bash profile. 同样,'哪个psql'的结果是这样的: /usr/bin/psql对我来说似乎/usr/bin/psql ,因为我已经在bash配置文件中添加了什么。

Um, not trying to prolong this post, nor add questions that could be saved for another post. 嗯,不是要延长这篇文章的时间,也不要添加可以保存到其他帖子的问题。 I guess technically since I've got both Navicat and Induction working that this post is now invalid? 从技术上讲,我想自从同时使Navicat和Induction都工作后,该帖子现在无效了吗?

Should I make my question about psql path another post? 我应该对psql path提出另一个问题吗?

Please let me know. 请告诉我。

Thank you. 谢谢。

Have removed results of echo $PATH. 已删除echo $ PATH的结果。

Seems like your rails app is trying to connect to the standard postgres installation that is shipped with OSX vs. the postgresapp. 似乎您的Rails应用程序正在尝试连接到OSX与postgresapp一起提供的标准postgres安装。

Have you followed these steps as part of the postgresapp setup ( http://postgresapp.com/documentation )? 您是否在postgresapp设置( http://postgresapp.com/documentation )中遵循了这些步骤?

PostgreSQL ships with a constellation of useful binaries, like pg_dump or pg_restore, that you will likely want to use. PostgreSQL附带了可能要使用的有用二进制文件,例如pg_dump或pg_restore。 Go ahead and add the /bin directory that ships with Postgres.app to your PATH (preferably in .profile, .bashrc, .zshrc, or the like to make sure this gets set for every Terminal session): 继续,将Postgres.app附带的/ bin目录添加到PATH(最好在.profile,.bashrc,.zshrc等文件中,以确保为每个Terminal会话设置了该目录):

PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH" PATH = “/应用/ Postgres.app /内容/ MacOS的/ bin中:$ PATH”

Once your path is correctly set up, you should be able to run psql without a host. 正确设置路径后,您应该可以在没有主机的情况下运行psql。 (If not, check that the correct version is being loaded in the PATH by doing which psql) (如果不是,请通过执行哪个psql来检查是否在PATH中加载了正确的版本)

Also, re-install your pg gem. 另外,重新安装您的pg gem。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM