当我尝试倾斜db:migrate时,出现错误:ActiveRecord :: NODatabaseError角色“ ubuntu”;不存在 [英] when I try to do rake db:migrate, I get an error: ActiveRecord::NODatabaseError role "ubuntu" does not exist
问题描述
我通过执行以下操作启动了PostgreSQL服务器:
I started the postgresql server by doing this:
sudo service postgresql start
然后我连接到该服务:
sudo sudo -u postgres psql
然后我创建了一个数据库(我正在尝试添加投票系统到我的应用程序):
then I created a database (i'm trying to add a voting system to my app):
postgres=# CREATE DATABASE "votes";
但我仍然遇到相同的问题。
but i still have the same problem.
此外,当我这样做时
rake db:create
我遇到一个角色 ubuntu不存在的错误
I get a role "ubuntu" does not exist error
这是我的数据库。yml:
Here is my database.yml:
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
# default: &default
# adapter: sqlite3
# pool: 5
# timeout: 5000
# development:
# <<: *default
# database: db/development.sqlite3
# # Warning: The database defined as "test" will be erased and
# # re-generated from your development database when you run "rake".
# # Do not set this db to the same as development or production.
# test:
# <<: *default
# database: db/test.sqlite3
# production:
# <<: *default
# database: db/production.sqlite3
# FOR HEROKU -- POSTGRES DB SETUP
# UNCOMMENT WHEN WORKING LOCALLY.
development:
adapter: postgresql
database: votes
pool: 5
timeout: 5000
username: ubuntu
test:
adapter: postgresql
database: planit_test
pool: 5
timeout: 5000
# production:
# <<: *default
# database: db/production.sqlite3
我尝试创建ubuntu rold:
I'm trying to create an ubuntu rold:
$ sudo sudo -u postgres psql
psql (9.3.10)
Type "help" for help.
postgres=# CREATE ROLE ubuntu SUPERUSER
postgres-# \q
$ rake db:migrate
rake aborted!
ActiveRecord::NoDatabaseError: FATAL: role "ubuntu" does not exist
推荐答案
关于角色 ubuntu的错误不存在
是由于用户(或 role
),您正试图使用该应用从应用程序访问您的Postgress会话。
The error you are getting about role "ubuntu" does not exist
is because of the user (or role
) that you are trying to use to access your postgress session from the app.
作为您的 database.yml
指定
development:
adapter: postgresql
database: votes
pool: 5
timeout: 5000
username: ubuntu
注意最后一行:用户名:ubuntu
?
您可以通过以下两种方式进行操作:
Two ways you can go about this are:
1)删除该行(也许将其注释掉)-这将使您的应用使用默认集名称(或 role
)连接到您的postgress会话您可能要调用它)。默认的大多数时间是 postgress
或您计算机上的用户名。
1) Remove that line (maybe comment it out) - This will make your app connect to your postgress session with the default set name (or role
, as you may want to call it). The default most times will be postgress
or your username on your machine.
2)创建角色 ubuntu
进行发布。为此,您可以查看此答案。
2) create the role ubuntu
for your postgress. To do this, you can check out this answer.
以上两种方法中的任何一种都应该对您有效。
Either of the above two ways should work well for you.
这篇关于当我尝试倾斜db:migrate时,出现错误:ActiveRecord :: NODatabaseError角色“ ubuntu”;不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!