1

I'm un running PostgreSQL version 11.8 in Windows Server 2016, and in PostgreSQL shell, I'm trying to import a dump database file that was exported using PostgreSQL version 8.4.20. However, get error as "database ... does not exist" Using Windows Dos command prompt, tried:

c:\Program Files\PostgreSQL\11\bin> pg_dump -U postgres C:\folderName\databaseName.dump > C:\AnotherFolderName\databasenew.sql

However, get an error as:

pg_dump: [archiver (db) connection to database C:\folderName\databaseName.dump" failed: FATAL "C:\folderName\databaseName.dump" does not exist 

Also, I tried removing the .dump extension as follows:

c:\Program Files\PostgreSQL\11\bin> pg_dump -U postgres C:\folderName\databaseName > C:\AnotherFolderName\databasenew2.sql

and get error, too:

pg_dump: [archiver (db) connection to database C:\folderName\databaseName" failed: FATAL "C:\folderName\databaseName" does not exist 
5
  • 1
    You need to specify the name of a database, not a folder name for pg_dump (or any Postgres command line tool) To get a list of available database names use psql -l. To "import" a SQL ("plain text") dump, you need to use psql -d database_name -f databasenew2.sql see the manual for details Commented Aug 10, 2020 at 20:10
  • Thanks, @a_horse_with_no_name . The .dump database was obtained from a different environment. I'm my Windows 2016 server, I saved such dump file into the an attached drive. I thought in Windows, I had to go c:\Program Files\PostgreSQL\11\bin and specify the folder location of the dump file. Thank you. Commented Aug 10, 2020 at 20:40
  • 2
    Are you loking for: pg_restore -f C:\AnotherFolderName\databasenew.sql C:\folderName\databaseName.dump? This will only work if C:\folderName\databaseName.dump was created using a custom format. If the dump file is a text file you will need to use psql. Commented Aug 10, 2020 at 20:46
  • 1
    You need to connect to an existing database (which is not the same as a folder). Once you can do that, you can run psql -d database_name -f databasenew2.sql to import the dump. See the manual for details Commented Aug 10, 2020 at 20:50
  • Thank you folks. I received .dump the file compressed in .gz format. In WindowsServer 2016, I unzipped and resulted C:\FolderName\databaseName.dump. Then, launched PgAdmin and created a database called 'databasenew'. In Windows CMD shell, ran C:\Program Files\PostgreSQL\11\bin> psql -U postgres Next, entered password for postgres. In postgres=#, ran psql -d databaseName.dump -f databasenew.sql . Then, returns to postgres=# prompt. PgAdmin UI does not show the "databasenew" Commented Aug 11, 2020 at 6:14

1 Answer 1

1

You need to restore your dump file, so you should feed it to pg_restore.

While pg_restore will do its best to read and interpret the 8.4 dump properly, the recommended practice is to dump the 8.4 database with pg_dump from v11.

Sign up to request clarification or add additional context in comments.

1 Comment

Note Larenz Albe. Thank you for your advice.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.