gpt4 book ai didi

ruby-on-rails - 试图让 Postgres 和 Postgis 在 Rails 应用程序中运行

转载 作者:行者123 更新时间:2023-11-29 13:35:29 26 4
gpt4 key购买 nike

我对 Postgresql、Postgis 和 SQL 完全陌生,对 Rails 有一点了解。我正在尝试让一个现有的应用程序在我的本地运行,并且在运行 rake 任务以设置我的数据库时当前收到以下消息。

Blane-Cordess-MacBook:ajungo blanecordes$ rake postgres:create_postgis_template --trace
(in /Users/blanecordes/ajungo)
** Invoke postgres:create_postgis_template (first_time)
** Execute postgres:create_postgis_template
Enter your postgres username: blane
Password for user blane:
psql (9.2.1, server 9.1.4)
WARNING: psql version 9.2, server version 9.1.
Some psql features might not work.
You are now connected to database "template1" as user "blane".
psql:assets/sql/postgis_template_osx.sql:2: ERROR: permission denied to create database
psql:assets/sql/postgis_template_osx.sql:6: ERROR: permission denied for relation pg_database
psql:assets/sql/postgis_template_osx.sql:7: \connect: FATAL: database "template_postgis" does not exist

我的 postgis_template_osx.sql 文件如下:

\c template1
CREATE DATABASE template_postgis WITH template = template1;

-- set the 'datistemplate' record in the 'pg_database' table for
-- 'template_postgis' to TRUE indicating its a template
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis';
\c template_postgis
CREATE LANGUAGE plpgsql ;
\i /usr/local/Cellar/postgis/2.0.1/share/postgis/postgis.sql;
\i /usr/local/Cellar/postgis/2.0.1/share/postgis/spatial_ref_sys.sql;
-- 1.5.2


-- in a production environment you may want to
-- give role based permissions, but granting all for now
GRANT ALL ON geometry_columns TO PUBLIC;
GRANT ALL ON spatial_ref_sys TO PUBLIC;

-- vacuum freeze: it will guarantee that all rows in the database are
-- "frozen" and will not be subject to transaction ID wraparound
-- problems.
VACUUM FREEZE;

最佳答案

PostgreSQL ROLE blane 没有创建数据库的权限。 ALTER blane 并添加 CREATEDB 选项或使用具有该功能的现有管理员角色。

postgres=# ALTER ROLE blane WITH CREATEDB;

关于ruby-on-rails - 试图让 Postgres 和 Postgis 在 Rails 应用程序中运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13596308/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com