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;
4

1 回答 1

1

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

postgres=# ALTER ROLE blane WITH CREATEDB;
于 2012-11-28T03:18:17.430 回答