postgresql13 for window 安裝及備份還原數據

postgresql13 for window 搭建及備份還原數據

安裝

  • 下載 win x86-64
    https://www.enterprisedb.com/download-postgresql-binaries

  • 初始化
    C:\install\postgres\pgsql\bin\initdb.exe -D C:\install\postgres\pgsql\data -E UTF8

  • 啓動服務
    C:\install\postgres\pgsql\bin\pg_ctl -D C:\install\postgres\pgsql\data -l logfile.log start

  • 查看進程是否啓動
    netstat -aon | findstr 5432

  • 登入
    C:\install\postgres\pgsql\bin\psql.exe postgres

  • 查看所有數據庫
    \l

  • 修改連接參數及work大小

  • 打開 C:\install\postgres\pgsql\data\postgresql.auto.conf

  • 添加

       # Do not edit this file manually!
       # It will be overwritten by the ALTER SYSTEM command.
    
       listen_addresses='*'
    
       max_connections=1000
       statement_timeout=1800000
       idle_in_transaction_session_timeout=600000
    
       max_parallel_workers=8
       max_parallel_workers_per_gather=6
    
  • 注意: 修改配置參數後簡易重啓數據庫

備份

  • 命令
    C:\install\postgres\pgsql\bin\pg_dumpall > D:\db\backup\pg_all_test.sql

恢復

  • 命令
    C:\install\postgres\pgsql\bin\psql -f D:\db\backup\pg_all_test.sql postgres

DB操作命令

  • 停止
    C:\install\postgres\pgsql\bin\pg_ctl -D C:\install\postgres\pgsql\data -l logfile.log stop

  • 啓動
    C:\install\postgres\pgsql\bin\pg_ctl -D C:\install\postgres\pgsql\data -l logfile.log start

  • 重載
    C:\install\postgres\pgsql\bin\pg_ctl -D C:\install\postgres\pgsql\data -l logfile.log reload

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章