postgresql Postgres 无权限创建用户
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18289366/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Postgres No permission to create user
提问by sayth
I am unable to use rails with postgres. The database wont create:
我无法在 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}
So I am following the solution here https://stackoverflow.com/a/8639649
所以我在这里遵循解决方案https://stackoverflow.com/a/8639649
These are the steps i am having issue with.
这些是我遇到问题的步骤。
$ psql -d postgres
postgres=# create role app_name login createdb;
postgres=# \q
However when I am in the psql shell to give the create role with createdb ability it fails auth.
但是,当我在 psql shell 中赋予具有 createdb 能力的 create 角色时,它无法通过身份验证。
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=>
How then do I create the auth?
那么我如何创建身份验证?
Edit Update Reviewing http://www.postgresql.org/docs/9.2/static/tutorial-createdb.htmlAnd http://www.postgresql.org/docs/9.2/static/database-roles.html
编辑更新http://www.postgresql.org/docs/9.2/static/tutorial-createdb.html和http://www.postgresql.org/docs/9.2/static/database-roles.html
But cannot use root to create accounts as it doesn't exist and I need to be root to create it.
但是不能使用 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
采纳答案by Audrius Meskauskas
The username / password you use lack the administrator rights that are necessary for creation users and databases.
您使用的用户名/密码缺乏创建用户和数据库所需的管理员权限。
Login as administrator and fix the permissions. If you have administrator login credentials, login and use ALTER ROLEto fix the rights on that account.
以管理员身份登录并修复权限。如果您有管理员登录凭据,请登录并使用ALTER ROLE来修复该帐户的权限。
回答by édouard Lopez
Add this using during gitlab_ci
DB setup. I solve the problem as described by @Audrius Me?kauskas
on Ubuntu 12.04
:
在gitlab_ci
DB setup期间使用添加它。我作为解决所描述的问题@Audrius Me?kauskas
上Ubuntu 12.04
:
Connect as Admin
以管理员身份连接
sudo -u postgres psql -d template1
Alter role
改变角色
ALTER ROLE gitlab_ci WITH CREATEDB;
Re-run the task
重新运行任务
sudo -u gitlab_ci -H bundle exec rake db:setup RAILS_ENV=production