关于PostgreSQL的数据库备份,请记住以下内容
简述
為了建立開發環境,我們有時候會從測試環境中備份一些東西,所以我稍微做個筆記。
答案仅限一个选项,以下是对“ダンプ”的中文释义:
填岛
在Postgres的情况下,如果角色和权限不能被正确地移植,应用程序将无法连接并出现错误,因此需要进行数据转储。
* 虽然只需要与特定数据库相关的信息,但不知道具体方法,所以先全部输出…
# ロールのみ
$ pg_dumpall -U postgres -h 127.0.0.1 --roles-only -p 5432 > ~/roles.sql
# 構造のみ
$ pg_dump -U postgres -h 127.0.0.1 -s -p 5432 --create example_db > ~/schema.sql
# データのみ
$ pg_dump -U postgres -h 127.0.0.1 -a -p 5432 example_db > ~/data.sql
恢复
$ psql -U postgres -f roles.sql
$ psql -U postgres -f schema.sql
$ psql -U postgres example_db < data.sql
PostgreSQL操作和权限
$ psql -d example_db -U hoge
¥d
¥d table_name
¥q
GRANT ALL * ON TO hoge;
以上