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,510 points
904 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!!

answered May 4, 2020 by Niroj
• 82,720 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
3 answers

MySQL "Could not create connection to database serve" error

Pls check that you have MySQL server ...READ MORE

answered Jul 3, 2020 in Database by anonymous
17,439 views
0 votes
1 answer
0 votes
2 answers

How to select the nth row in a SQL database table?

SELECT * FROM ( SELECT ID, NAME, ROW_NUMBER() ...READ MORE

answered Apr 23, 2020 in Database by anand
• 140 points
8,761 views
0 votes
1 answer

ERROR 1006 (HY000): Can't create database 'test' (errno: 2) in mysql

Hi@akhtar, You have to change the permissions or ...READ MORE

answered Apr 14, 2020 in Database by MD
• 95,160 points
1,938 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,720 points
9,454 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,720 points
1,569 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,720 points
130 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,720 points
136 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,720 points
179 views