繁体   English   中英

postgresql 使用 dumpall 文件还原数据库

[英]postgresql restore database using dumpall file

我打算使用此命令中提到的以下命令来转储和恢复我的数据库 -

https://www.postgresql.org/docs/current/app-pg-dumpall.html

To dump all databases:

$ pg_dumpall > db.out
To reload database(s) from this file, you can use:

$ psql -f db.out postgres

当我使用 dump all 它会转储所有数据库时,为什么我需要在我的还原命令中指定...

ie; psql -f db.out postgres

postgres 在这里意味着什么?

$ psql --help
psql is the PostgreSQL interactive terminal.

Usage:
  psql [OPTION]... [DBNAME [USERNAME]]

General options:
  -c, --command=COMMAND    run only single command (SQL or internal) and exit
  -d, --dbname=DBNAME      database name to connect to (default: "tramfjord")
  -f, --file=FILENAME      execute commands from file, then exit

psql -f /my/file postgres , postgres 是DBNAME或数据库名称。 您的用户名可能会默认为 postgres。

使用这个简单的命令:

remove *-h localhost* 

如果你没有主机

su postgres    
psql -h localhost dump_database_name < /tmp/dump_all.sql

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM