Neurohazard
暮雲煙月,皓首窮經;森羅萬象,如是我聞。

PostgreSQL 基础操作

wpadmin~December 9, 2019 /System Management

Contents

PostgreSQL 基础操作

备份数据

# 用 psql 恢复
pg_dump -U postgres -f /tmp/pg1.sql <database_name>

# 用 pg_restore 恢复 借助 pgAdmin 工具
pg_dump --file /tmp/pg2.sql --username postgres --verbose --format=c --blobs --encoding "UTF-8" "mooder"

导入数据

postgres=# CREATE DATABASE mooder OWNER postgres;
CREATE DATABASE
postgres-# \c mooder
您现在已经连接到数据库 "mooder",用户 "postgres".


CREATE USER 用户名 WITH PASSWORD '*****';

cmd

C:\"Program Files"\PostgreSQL\12\bin\psql.exe -U postgres mooder < pg1.sql
pg_restore --host localhost --port 5432 --username "postgres" --no-password --dbname "mooder" --verbose /tmp/pg2.sql

编译安装 postgresql

https://www.postgresql.org/docs/9.4/install-procedure.html
https://www.manniwood.com/2017_11_01/postgresql_10_compile_install_howto.html

参考资料

PostgreSQL 新手入门
https://www.ruanyifeng.com/blog/2013/12/getting_started_with_postgresql.html

postgres备份
https://www.jianshu.com/p/233b064efa67

Leave a Reply

Your email address will not be published. Required fields are marked *