Import SQL dump into PostgreSQL database

Web Technologies Web Development 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating
_x000D_ _x000D_ 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?

Posted on 16 Aug 2022, this text provides information on Web Development related to Web Technologies. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago
_x000D_ 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.

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

Important Web Technologies Links