我无法在 postgres 中使用 rails。数据库不会创建:
sayth@sayth-TravelMate-5740G:~/testapp2$ rake db:create:all
PG::InsufficientPrivilege: ERROR: permission denied to create database
: CREATE DATABASE "testapp2_development" ENCODING = 'unicode'
....
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "database"=>"testapp2_production", "pool"=>5, "username"=>"testapp2", "password"=>nil}
所以我在这里关注解决方案https://stackoverflow.com/a/8639649
这些是我遇到问题的步骤。
$ psql -d postgres
postgres=# create role app_name login createdb;
postgres=# \q
但是,当我在 psql shell 中为 create 角色赋予 createdb 能力时,它会通过身份验证失败。
sayth@sayth-TravelMate-5740G:~/testapp2$ psql -d postgres
psql (9.2.4)
Type "help" for help.
postgres=> create role sayth createdb;
ERROR: permission denied to create role
postgres=>
那么如何创建身份验证?
编辑更新审查http://www.postgresql.org/docs/9.2/static/tutorial-createdb.html 和http://www.postgresql.org/docs/9.2/static/database-roles.html
但不能使用 root 来创建帐户,因为它不存在,我需要成为 root 才能创建它。
sayth@sayth-TravelMate-5740G:~$ sudo psql -d postgres
[sudo] password for sayth:
Sorry, try again.
[sudo] password for sayth:
psql: FATAL: role "root" does not exist