将sql dump导入postgresql数据库(Import SQL dump into PostgreSQL database)

编程入门 行业动态 更新时间:2024-10-10 13:18:09
将sql dump导入postgresql数据库(Import SQL dump into PostgreSQL database)

我们正在切换主机,旧的提供了我们网站的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_dump

That'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.

更多推荐

本文发布于:2023-08-05 17:32:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1437195.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据库   postgresql   dump   sql   database

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!