Error Import SQL dump into PostgreSQL database

0 votes

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?

May 4, 2020 in Database by kartik
• 37,520 points
5,297 views

1 answer to this question.

0 votes

Hello,

Here is the command you are looking for.

psql -h hostname -d databasename -U username -f file.sql

Thank You!!

Also Read:

Is there a way to connect to a POSTGRESQL DB which is encrypted AES?

answered May 4, 2020 by Niroj
• 82,840 points
psql:laravel-vue123.DB.SQL.sql:156444: error: invalid command \'s

l:laravel-vue123.DB.SQL.sql:151110: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:151112: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:151140: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:151142: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:151144: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:151281: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:151283: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:151286: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:152409: error: invalid command \'s',
psql:laravel-vue123.DB.SQL.sql:152757: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:153978: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:154125: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:155075: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:155138: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:155422: error: invalid command \'
psql:laravel-vue123.DB.SQL.sql:155661: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:155684: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:155708: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:155782: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:155823: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:155883: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:155974: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:156011: error: invalid command \'
psql:laravel-vue123.DB.SQL.sql:156023: error: invalid command \'DAM
psql:laravel-vue123.DB.SQL.sql:156094: error: invalid command \'automobile,
psql:laravel-vue123.DB.SQL.sql:156131: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:156154: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:156178: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:156252: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:156293: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:156353: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:156444: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:156481: error: invalid command \'
psql:laravel-vue123.DB.SQL.sql:156493: error: invalid command \'DAM
psql:laravel-vue123.DB.SQL.sql:156563: error: invalid command \'automobile,
psql:laravel-vue123.DB.SQL.sql:156619: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:156660: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:156720: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:156812: error: invalid command \'s
psql:laravel-vue123.DB.SQL.sql:156849: error: invalid command \'
psql:laravel-vue123.DB.SQL.sql:156861: error: invalid command \'DAM
psql:laravel-vue123.DB.SQL.sql:156931: error: invalid command \'automobile,
psql:laravel-vue123.DB.SQL.sql:157065: ERROR:  syntax error at o

Related Questions In Database

0 votes
0 answers

Import CSV file into SQL Server

I have a few fundamental questions and ...READ MORE

Aug 14, 2022 in Database by Kithuzzz
• 38,000 points
1,033 views
0 votes
0 answers

Import .bak file to a database in SQL server

I have a file with .bak extension. How ...READ MORE

Aug 14, 2022 in Database by Kithuzzz
• 38,000 points
504 views
0 votes
0 answers

SQL Server database restore error: specified cast is not valid. (SqlManagerUI)

For my production website, SQL Server 2008 ...READ MORE

Aug 20, 2022 in Database by Kithuzzz
• 38,000 points
1,473 views
0 votes
0 answers

Display data from SQL database into php/ html table.

I want to display one of my ...READ MORE

Aug 27, 2022 in Database by Kithuzzz
• 38,000 points
870 views
0 votes
1 answer
0 votes
1 answer

MySQL Error: : 'Access denied for user 'root'@'localhost'

Hello @kartik, I did this to set my ...READ MORE

answered May 4, 2020 in Database by Niroj
• 82,840 points
18,451 views
0 votes
1 answer

Error Code: 2020. Lost connection to MySQL server during query

Hello @kartik, I got the same issue when ...READ MORE

answered May 4, 2020 in Database by Niroj
• 82,840 points
2,712 views
0 votes
1 answer

How to empty a redis database?

Hello @kartik, You have two options: FLUSHDB - clears currently ...READ MORE

answered May 4, 2020 in Database by Niroj
• 82,840 points
985 views
+1 vote
1 answer

How to migrate a PostgreSQL database into a SQLServer one?

Hello @kartik, The easier way to accomplish this. First ...READ MORE

answered May 13, 2020 in Database by Niroj
• 82,840 points
1,039 views
0 votes
1 answer

Sir please tell me how to import image in database?

Hello soumadip, (Assuming you are using mysql database) You ...READ MORE

answered Apr 1, 2020 in Database by Niroj
• 82,840 points
1,019 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP