我们正在切换主机,旧的提供了我们网站的postgresql数据库的sql转储。 现在我试图将它设置在一个本地的wamp服务器上来测试。
唯一的问题是,我没有一个想法如何我可以导入这个数据库在我已经设置的postgresql 9。
我尝试过pgAdmin III,但似乎找不到“导入”功能。 所以我刚刚打开SQL编辑器并粘贴了转储的内容并执行它,它创建了表,但是当他尝试将数据放在其中时,我一直在给我错误。
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 ...我也尝试使用命令提示符,但我找不到我需要的命令。
如果我做
psql mydatabase < C:/database/db-backup.sql;我得到错误
ERROR: syntax error at or near "psql" LINE 1: psql mydatabase < C:/database/db-backu... ^导入数据库的最佳方法是什么?
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 server to test this.
The only problem is that I don't have an idea how to import this database in the PostgreSQL 9 that I have set up.
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 it keeps giving me errors when it 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 do this with the command prompt but I can't find the command that I need.
If I do
psql mydatabase < C:/database/db-backup.sql;I get the error
ERROR: syntax error at or near "psql" LINE 1: psql mydatabase < C:/database/db-backu... ^What's the best way to import the database?
最满意答案
psql databasename < data_base_dump这是你正在寻找的命令。
小心:在导入之前必须创建数据库名称。 看看PostgreSQL文档第23章备份和还原 。
psql databasename < data_base_dumpThat's the command you are looking for.
Beware: databasename must be created before importing. Have a look at the PostgreSQL Docs Chapter 23. Backup and Restore.
更多推荐
发布评论