且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PostgreSQL:致命:角色不存在

更新时间:2022-10-31 13:43:07

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



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



特别是救了我的那行是 createdb'whoami'请参阅实际文章...语法与我的语法有点不同刚写是因为***格式)...回想起来很明显,但是它通过实际创建 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 *** 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!