当我尝试在本地处理项目时,我切换到了新的Macbook。
当我运行rails s
时,它会不断告诉我本地数据库不存在。
当我尝试运行时:
rake db:create
它告诉我,没有用户名为myusername
我跑了psql -U postgres
然后我跑了\du
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
name | Superuser, Create role, Create DB | {}
dev | Create DB | {}
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
name2 | Superuser, Create role, Create DB | {}
我可以在那里看到我的用户有权访问数据库。
答案 0 :(得分:0)
我能够通过运行来解决此问题
psql -U postgres
postgres=# \du
查看用户列表。
找到用户后,我会去config/database.yml
我将用户名设置为开发中
development:
<<: *default
database: swiftypost_development
# The specified database role being used to connect to postgres.
# To create additional roles in postgres see `$ createuser --help`.
# When left blank, postgres will use the default role. This is
# the same name as the operating system user that initialized the database.
username: my_username