我做这个启动PostgreSQL服务器:当我尝试做耙分贝:迁移,我得到一个错误:的ActiveRecord :: NODatabaseError作用“Ubuntu的”不存在
sudo service postgresql start
然后我连接到服务:
sudo sudo -u postgres psql
然后我创建了一个数据库(我试图投票系统添加到我的应用程序):
postgres=# CREATE DATABASE "votes";
,但我仍然公顷有同样的问题。
此外,当我做
rake db:create
我得到一个角色 “Ubuntu的” 不存在错误
这里是我的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:
$ 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
你有你的配置databases.yml中:
然后
你可以,如果角色存在,或者不使用命令检查? – Guido
检查'database.yml'并更改用户名。如果你想连接用户'ubuntu',那么你必须先在postgres中创建它。检查[创建角色](http://www.postgresql.org/docs/8.3/static/sql-createrole.html)文档。在你创建它之后,请确保你具有正确的权限[改变角色](http://www.postgresql.org/docs/9.0/static/sql-alterrole.html)。 – radubogdan
是的,我连接到服务。然后我做了创建用户ubuntu SUPERUSER。 usernmae“ubuntu”位于我的database.yml文件中。仍然有同样的问题 – coderk