导入sql dump到postgresql数据库 [英] import sql dump into postgresql database

查看:1157
本文介绍了导入sql dump到postgresql数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在切换主机,旧的提供了我们网站的postgresql数据库的SQL转储。
现在我试图在本地wamp服务器上设置这个测试这个。

We are switching hosts and the old one provided a sql dump of the postgresql database of our site. Now I'm trying to set this up on a local wamp sever to test this.

唯一的问题是,我没有一个想法我可以导入这个数据库在PostgreSQL 9我已经设置。

The only problem is that i don't have an idea how i can import this database in the postgresql 9 i have set up.

我试过pgAdmin III,但我似乎找不到一个'import'函数。所以我只是打开SQL编辑器并粘贴转储的内容,并执行它,它创建表,但我不断给我错误,当他尝试把数据放入其中。

I tried pgAdmin III but i can't seem to find an 'import' function. So i just opened the SQL editor and pasted the contents of the dump there and executed it, it creates the tables but i keeps giving me errors when he tries to put the data in it.

ERROR:  syntax error at or near "t"
LINE 474: t 2011-05-24 16:45:01.768633 2011-05-24 16:45:01.768633 view...

The lines:
COPY tb_abilities (active, creation, modtime, id, lang, title, description) FROM stdin;
t   2011-05-24 16:45:01.768633  2011-05-24 16:45:01.768633  view    nl ...  

我也尝试过这个命令提示符,但我不能真正找到我需要的命令。

I've also tried to this with the command prompt but i can't really find the command that i need.

如果我做

psql mydatabase < C:/database/db-backup.sql;

我得到错误

ERROR:  syntax error at or near "psql"
LINE 1: psql mydatabase < C:/database/db-backu...
        ^

导入数据库?

推荐答案

psql databasename < data_base_dump

这是您要查找的命令。

That's the command you are looking for.

注意:必须先创建databasename,然后才能导入。
请查看 PostgreSQL文档第23章。备份和恢复

Beware: databasename must be created before importing. Have a look at the PostgreSQL Docs Chapter 23. Backup and Restore.

这篇关于导入sql dump到postgresql数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆