简体   繁体   English

ActiveRecord::StatementInvalid: PG::InsufficientPrivilege: ERROR: permission denied to create database in the rails 7

[英]ActiveRecord::StatementInvalid: PG::InsufficientPrivilege: ERROR: permission denied to create database in the rails 7

I got this below error while creating a database in the rails application在 Rails 应用程序中创建数据库时出现以下错误

$ rails db:create
PG::InsufficientPrivilege: ERROR:  permission denied to create database
Couldn't create 'app_development' database. Please check your configuration.
rake aborted!
ActiveRecord::StatementInvalid: PG::InsufficientPrivilege: ERROR:  permission denied to create database

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

Tasks: TOP => db:create
(See full trace by running task with --trace)

This solution is worked for me, You can try the same if you face this error while rails db:create in the rails application.这个解决方案对我有用,如果在 rails 应用程序中rails db:create时遇到此错误,您可以尝试相同的方法。

$ sudo -u postgres -i
$ psql
postgres=# ALTER USER user_name CREATEDB;
ALTER ROLE
postgres=# create database "database_name" owner "user_name";
CREATE DATABASE
postgres=# GRANT ALL PRIVILEGES ON  DATABASE database_name to user_name;
GRANT
postgres=# ALTER DATABASE blog_development owner to user_name;
ALTER DATABASE

after the above steps run this rails db:create and it will work.完成上述步骤后,运行此rails db:create

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ActiveRecord::StatementInvalid (PG::InsufficientPrivilege: ERROR: permission denied for relationship - ActiveRecord::StatementInvalid (PG::InsufficientPrivilege: ERROR: permission denied for relation PG::InsufficientPrivilege: 错误:创建数据库 Ruby on Rails 应用程序的权限被拒绝 - PG::InsufficientPrivilege: ERROR: permission denied to create database Ruby on rails application Ubuntu / Rails PG :: InsufficientPrivilege:错误:拒绝创建数据库的权限 - Ubuntu/Rails PG::InsufficientPrivilege: ERROR: permission denied to create database ActiveRecord :: StatementInvalid:PG :: InsufficientPrivilege:错误:关系schema_migrations的权限被拒绝 - ActiveRecord::StatementInvalid: PG::InsufficientPrivilege: ERROR: permission denied for relation schema_migrations PG rails db:create InsufficientPrivilege: ERROR: permission denied to create db - PG rails db:create InsufficientPrivilege: ERROR: permission denied to create db RAILS:PG::InsufficientPrivilege:错误:创建扩展“pgcrypto”的权限被拒绝提示:必须是超级用户才能创建此扩展 - RAILS : PG::InsufficientPrivilege: ERROR: permission denied to create extension "pgcrypto" HINT: Must be superuser to create this extension Rails:PG::InsufficientPrivilege:错误:关系 schema_migrations 的权限被拒绝 - Rails: PG::InsufficientPrivilege: ERROR: permission denied for relation schema_migrations Ruby on Rails INSERT 错误 ***** PG::InsufficientPrivilege: 错误:关系发票的权限被拒绝 - Ruby on Rails INSERT Error ***** PG::InsufficientPrivilege: ERROR: permission denied for relation invoices PG::InsufficientPrivilege at / 错误:关系 schema_migrations 的权限被拒绝 - PG::InsufficientPrivilege at / ERROR: permission denied for relation schema_migrations ActiveRecord :: StatementInvalid:PG :: UndefinedTable:错误:在Rails查询中 - ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: in rails query
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM