2016-03-05 119 views
0

我使用的是Ubuntu 15.10版。我在终端上键入rails s后启动的Ruby应用程式,前往0.0.0.0:3000,我得到的网页上出现以下错误:NoDatabaseError运行Ruby Rails应用程序

ActiveRecord::NoDatabaseError at /

FATAL: database "local-election_development" does not exist Run $ bin/rake db:create db:migrate to create your database

当我从终端上键入bin/rake db:create db:migrate,我得到这个错误:

PG::InsufficientPrivilege: ERROR: permission denied to create database

我发现this answer,但我不知道如何执行ALTER USER new_user CREATEDB;命令。

我该如何解决这个错误?

回答

1

登录到Postgres用户:

su - postgres 

登录到通过键入:

psql 

您现在应该看到Postgres的提示=#

+0

输入'psql'后,它会要求输入密码。如果我忘记了,我该如何重置它? – badjr

+1

http://stackoverflow.com/questions/10845998/i-forgot-the-password-i-entered-during-postgres-installation这个答案会帮助你 –

2

您可以到在PostgreSQL控制台上输入SQL命令,该命令可以用psql调用。

如果它抱怨数据库不存在,则使用createdb,如果用户不存在,则使用createuser。如果您遇到任何问题,请搜索与PostgreSQL相关的问题。

+0

输入psql后,它会要求输入密码。如果我忘记了,我该如何重置它? – badjr

+1

请尝试[此帖](http://stackoverflow.com/questions/10845998/i-forgot-the-password-i-entered-during-postgres-installation)或[Google](https://www.google。 co.uk/search?q=reset+postgres+password) – Leventix