2014-02-25 65 views
2

我一直在尝试导入一个postgres转储(使用psql dbname < dump.sql及其变体,指定主机名和用户名等),但到目前为止我一直没有成功。PostgreSQL导入不起作用

我是Postgres的新手,所以我可能在这里忽略了一些明显的问题。根据导入命令的输出,扩展plpgsql可能不存在。我希望在导入之前设置plpgsql扩展名?

以下是输出的前几行:

SET 
ERROR: unrecognized configuration parameter "lock_timeout" 
SET 
SET 
SET 
SET 
CREATE EXTENSION 
ERROR: must be owner of extension plpgsql 
ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/hstore.control": No such file or directory 
ERROR: extension "hstore" does not exist 
SET 
SET 
SET 
ERROR: relation "active_admin_comments" already exists 
ERROR: role "finalstep" does not exist 
ERROR: relation "active_admin_comments_id_seq" already exists 
ERROR: role "finalstep" does not exist 
ALTER SEQUENCE 
ERROR: relation "admin_users" already exists 
ERROR: role "finalstep" does not exist 

后来在路上,它看起来像它试图执行一些内容为SQL查询(内容包含MATHML标签)的:

ERROR: syntax error at or near "</" 
LINE 1: </mo> <msqrt> 
     ^
ERROR: syntax error at or near "&" 
LINE 1: &nbsp; 
     ^
ERROR: syntax error at or near "</" 
LINE 1: </mi> <mi>&alpha; 

任何指针?我的Postgres版本是9.1(最初是9.3,但在看到错误信息后我将它降级到了9.1)。

回答

3

很难说没有文件本身。一些指针:

  • 我要坚持版本9.3如果在所有可能的。对9.1的许多改进,您需要更多时间才能再次升级。 此外,第一错误信息表明您需要的Postgres 9.3无论如何,由于GUC(配置设置)lock_timeout was introduced with Postgres 9.3.

  • 使用psql with the -f switch以获得更详细的错误信息:

    psql dbname -f dump.sql 
    

    (而且也没有-dbname面前: ,这只是一个错字,我假设)

  • Langua? ge plpgsql如果您的安装未损坏,则不应该成为问题。 Per documentation:

    在PostgreSQL 9.0和更高版本,PL/pgSQL的默认安装。

  • 这些错误消息指示在操作系统级别从您的contrib包中读取文件时出现问题。

    ERROR: must be owner of extension plpgsql 
    ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/hstore.control": No such file or directory 
    ERROR: extension "hstore" does not exist 
    
    • 需要安装象hstore附加模块的可选包(分别或postgresql-contrib-9.3postgresql-contrib-9.1。在这个相关答案细节:
      Error when creating unaccent extension on PostgreSQL

    • 的文件必须于开始Postgres的,通常postgres(操作系统用户)系统的用户访问。也就是说,在shell中输入whoami时,答案应该是postgres

    • 此外,您必须以超级用户身份执行bash命令,通常为postgres(数据库用户)。通常,如果您未指定用户名,并且IDENTPEER认证已启用(默认),则会自动使用与OS用户匹配的数据库用户。在这个相关答案细节:
      Run batch file with psql command without password
+0

感谢您的帮助,固定-dbname错字。切换到9.3,它解决了一些问题。安装postgres-contrib-9.3,但问题仍然存在。我正在尝试一些事情,我会回到这里来发布我的进度。 – Soumendra