2017-10-13 33 views
1

只是想從資源恢復教程數據庫: http://www.postgresqltutorial.com/load-postgresql-sample-database/pg_restore使用zip文件?

所以,這個代碼後

pg_restore -U postgres -d dvdrental /Users/fedotarte/Downloads/dvdrental.zip 

我得到當前消息:

pg_restore的:[歸檔]輸入文件未出現成爲有效的檔案

what shoul我做的是成功恢復數據庫嗎?

預先感謝您!

+0

解壓縮 - 裏面有什麼?tar?傾倒?壓縮轉儲? –

+1

[引自下載頁面](http://www.postgresqltutorial.com/postgresql-sample-database/):「*數據庫文件在zipformat(dvdrental.zip)中,因此您需要提取它到dvdrental.tar *「。一旦你有了,按照[將示例數據庫加載到PostgreSQL數據庫服務器]的鏈接(http://www.postgresqltutorial.com/load-postgresql-sample-database/) –

+0

你好,@VaoTsun,有.dat文件和restore.sql –

回答

1

如下因素我解壓縮文件中的unstructions,找到一個tar文件後,用命令恢復:

-bash-4.2$ pg_restore -d dd -F t /tmp/dvdrental.tar 

所以你打算指定格式tar與-F t

-bash-4.2$ psql -d dd -c "\dt+" 
          List of relations 
Schema |  Name  | Type | Owner | Size | Description 
--------+---------------+-------+----------+------------+------------- 
public | actor   | table | postgres | 40 kB  | 
public | address  | table | postgres | 88 kB  | 
public | category  | table | postgres | 8192 bytes | 
public | city   | table | postgres | 64 kB  | 
public | country  | table | postgres | 8192 bytes | 
public | customer  | table | postgres | 96 kB  | 
public | film   | table | postgres | 464 kB  | 
public | film_actor | table | postgres | 264 kB  | 
public | film_category | table | postgres | 72 kB  | 
public | inventory  | table | postgres | 224 kB  | 
public | language  | table | postgres | 8192 bytes | 
public | payment  | table | postgres | 888 kB  | 
public | rental  | table | postgres | 1224 kB | 
public | staff   | table | postgres | 16 kB  | 
public | store   | table | postgres | 8192 bytes | 
(15 rows)