Postgres无权创建用户
我无法使用带有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中为createb赋予create role时,它会失败。
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=>
那怎么创建auth?
编辑更新审核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
您使用的用户名/密码缺少创建用户和数据库所需的管理员权限。
以管理员身份登录并修复权限。 如果您拥有管理员登录凭据,请登录并使用ALTER ROLE修复该帐户的权限。
在gitlab_ci
数据库设置期间添加此项。 我在Ubuntu 12.04
上解决了@Audrius Meškauskas
所描述的问题:
以管理员身份连接
sudo -u postgres psql -d template1
改变角色
ALTER ROLE gitlab_ci WITH CREATEDB;
重新运行任务
sudo -u gitlab_ci -H bundle exec rake db:setup RAILS_ENV=production
- Rails / Postgres:“必须出现在GROUP BY子句中或用于聚合函数”
- Postgresql“没有pg_hba.conf条目”错误
- 在PostgreSQL中使用Sequel gem插入一个数组
- SQLite到Postgres(Heroku)GROUP BY
- Rails 4 where,order,group,count包括零 – postgresql
- 需要将Postgres(== String)中的布尔值转换为Ruby布尔值
- 如何通过Rails 3中的时间片(总和,平均值,最小值,最大值等)获取聚合数据
- Rails ActiveRecord – 如何在两个日期之间获取记录
- 为了Heroku,从MySQL切换到PostgreSQL用于Ruby on Rails