[英]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.