好的,所以我对RDS和AWS还是很陌生,但是我一辈子都无法将自己在笔记本电脑上创建的数据库转移到Amazon RDS上,确实将其移至测试VPS和台式机上,一点问题都没有,这是到目前为止我尝试过的。
create extension postgis;
create extension fuzzystrmatch;
create extension postgis_tiger_geocoder;
create extension postgis_topology;
alter schema tiger owner to rds_superuser;
alter schema topology owner to rds_superuser;
CREATE FUNCTION exec(text) returns text language plpgsql volatile AS $f$ BEGIN EXECUTE $1; RETURN $1; END; $f$;
SELECT exec('ALTER TABLE ' || quote_ident(s.nspname) || '.' || quote_ident(s.relname) || ' OWNER TO rds_superuser')
FROM (
SELECT nspname, relname
FROM pg_class c JOIN pg_namespace n ON (c.relnamespace = n.oid)
WHERE nspname in ('tiger','topology') AND
relkind IN ('r','S','v') ORDER BY relkind = 'S')
s;
GRANT ALL PRIVILEGES ON DATABASE testgetwork TO luke;
然后,我连接到数据库并尝试加载新数据库的本地副本...
luke@l-xps:~$ psql --host=myhost.dns.us-west-2.rds.amazonaws.com --port=5432 --username=luke --password --dbname=testgetwork < testgetwork.sql
Password for user luke:
SET
SET
SET
SET
SET
ERROR: schema "topology" already exists
ALTER SCHEMA
CREATE EXTENSION
ERROR: must be owner of extension plpgsql
CREATE EXTENSION
ERROR: must be owner of extension postgis
CREATE EXTENSION
ERROR: must be owner of extension postgis_topology
<more output, removed to save space>
ERROR: permission denied for relation spatial_ref_sys
invalid command \.
setval
--------
1
(1 row)
setval
<more output, removed to save space>
我的问题是,我怎样才能从这里继续前进?所有功能似乎都由于权限问题而被阻止,用户luke是rds_superuser组的一部分,任何具有PostGis和RDS经验的人都知道我该如何解决?
testgetwork=> \du
List of roles
Role name | Attributes | Member of
---------------+------------------------------------------------+-----------------
luke | Create role, Create DB | {rds_superuser}
rds_superuser | Cannot login | {}
rdsadmin | Superuser, Create role, Create DB, Replication | {}
最佳答案
在RDS上设置PostGIS的官方指南是here。
那对我有用。
我在导入数据时仍然遇到问题,得到:
...
must be superuser to create a base type
permission denied for language c
....
有什么想法吗?
另外,是否可以以rdsadmin身份登录?