试图让Postgres和Postgis在Rails应用程序中运行

问题描述 投票:1回答:1

我是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;
ruby-on-rails postgresql postgis postgresql-9.1 rails-postgresql
1个回答
1
投票

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

postgres=# ALTER ROLE blane WITH CREATEDB;
© www.soinside.com 2019 - 2024. All rights reserved.