PostgreSQL:致命:角色不存在 [英] Postgresql: FATAL: role does not exist

查看:213
本文介绍了PostgreSQL:致命:角色不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设置要与Rails应用程序一起使用的Postgresql,但是我似乎无法连接或正确配置数据库(启动Rails服务器后出现的错误是: ActiveRecord :: NoDatabaseError 无法将主机名 MyProfile转换为地址:提供的节点名或服务名,或者未知)。



我从这个问题上需要解决的数十个其他问题中收集或创建了 MyComputer角色,但是我注意到它们都需要使用 psql 命令。当我什至只运行 psql 时,我再次收到错误 FATAL:角色 MyProfile不存在。 / p>

到目前为止,我一直在关注Heroku的安装过程,并被困在此处(或更准确地说,安装后,在这里,Heroku表示运行 psql -h localhost 应该可以)。我是否在这里错过了一个明显的步骤/做错了什么?



我也尝试过:


sudo su-MyProfile

sudo的变体-u postgres createuser owning_user


和一个几个其他命令来创建此工作卷/用户,但似乎无法完成解决此问题所需的工作。



编辑

我还运行了 ps aux | grep postgres ,看起来与所有与postgres关联的PID都在 MyProfile下运行(假设我没看错)。但是psql命令仍然返回该角色不存在。 #sadface



编辑2

我刚刚打开Postgres应用程序并单击打开psql按钮。它打开终端,运行命令('/ Applications / Postgres.app / Contents / Versions / 9.5 / bin'/ psql -p5432 ),然后出现相同的错误( psql:严重:角色 MyProfile不存在)。



编辑3

,这也许向我表明这是系统问题,而不是Rails问题?这当然是pg问题,而不是rails问题。我只是卸载了该应用程序,然后使用SQLite(库)重新安装了该应用程序,运行了本地服务器,并显示了测试登录页面。因此,问题似乎出在我的本地计算机上,而不是应用程序本身。删除了RoR标记,并且仍在Postgres专家中寻找有关角色问题仍然存在的原因的答案:)

解决方案

真是一团糟。 。我忘了提到的一件事可能会对社区产生天文数字的帮助,那就是我要接管别人的机器。



最终,我摆脱了Postgress.app,并使用Homebrew安装了postgres。 ,而我所需的平衡权在这里: http://exponential.io/blog/2015/02/21/install-postgresql-on-mac-os-x-via-brew/



特别是救了我的那行是 createdb'whoami'请参阅实际文章...语法与我的语法有点不同刚写是因为stackoverflow格式)...回想起来很明显,但是它通过实际创建 psql的数据库来帮助我当前登录的用户克服了其他旧用户的预设整个设置都在寻找。



经验教训!



感谢help @max,帮助我避免了我也会引起的另一个问题!


I'm setting up Postgresql for use with a Rails app, but I do not seem to be able to connect to, or properly configure, the database (the errors I get after starting the Rails server are: ActiveRecord::NoDatabaseError and could not translate host name "MyProfile" to address: nodename nor servname provided, or not known).

I gather from the dozens of other questions on this topic that I need to switch to, or create the "MyComputer" role, however I've noticed that they all require using the psql command. When I run even just psql I, again, get the error FATAL: role "MyProfile" does not exist.

So far I've been following Heroku's instal process and am stuck here (or more accurately here, after the installation, where Heroku says that running psql -h localhost should work). Am I missing an obvious step here/doing something wrong?

I've also tried:

sudo su - MyProfile
variations of sudo -u postgres createuser owning_user

and a couple other commands in an effort to create this roll/user, but I can't seem to get done what I need to to resolve the issue.

EDIT
I've also run ps aux | grep postgres and it looks like all the PID's that are associated with anything postgres are running under "MyProfile" (assuming I'm reading it right). But the psql command still returns that the role does not exist. #sadface

EDIT 2
I just opened the Postgres App and clicked the "Open psql" button. It opened the Terminal, ran a command ('/Applications/Postgres.app/Contents/Versions/9.5/bin'/psql -p5432) and then gave me the same error (psql: FATAL: role "MyProfile" does not exist). Which perhaps suggests to me that it's an system issue, and not a Rails issue at all?

Edit 3
This is most certainly a pg issue, not a rails issue. I just uninstalled the app, reinstalled it using SQLite (yucks), ran the local server and got the test landing page to show up. So the problem appears to be with my local machine but not the app itself. Removed RoR tag, and still looking for answers from Postgres gurus on why the role issue persists :)

解决方案

What a mess...one thing that I forgot to mention that probably would have been astronomically helpful to the community is that I'm taking over someone else's machine. There were lingering settings that just decided they weren't going to play nice.

At the end of the day, I got rid of Postgress.app, installed postgres with Homebrew, and the balance of what I needed was here: http://exponential.io/blog/2015/02/21/install-postgresql-on-mac-os-x-via-brew/

Specifically the line that saved me was createdb 'whoami' (see the actual post...the syntax is a bit different than what I just wrote because of stackoverflow formatting)...in retrospect it seems obvious, but it helped my current logged in user overcome the presets of the other legacy user by actually creating the database that the psql the whole setup was looking for.

Lesson learned!

Thanks for the help @max, helped me avoid another issue I was about to cause as well!

这篇关于PostgreSQL:致命:角色不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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