Last active
May 15, 2019 02:53
-
-
Save ajaxsys/3a21d676516cc358308c480f095cc65c to your computer and use it in GitHub Desktop.
Revisions
-
ajaxsys revised this gist
May 15, 2019 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ REM windows下,操作zip版postgres常用命令。参数的意义请参照官方文档 REM zip版postgres下载地址:https://www.enterprisedb.com/download-postgresql-binaries REM 设置为postgres zip版本解压缩路径<path_to_pgsql> set PG_HOME=<path_to_pgsql> -
ajaxsys created this gist
May 15, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ REM windows下,操作zip版postgres常用命令。参数的意义请参照官方文档 REM 设置为postgres zip版本解压缩路径<path_to_pgsql> set PG_HOME=<path_to_pgsql> cd %PG_HOME% REM 自定义数据库保存文件夹 mkdir data REM 初始化数据库服务,用户名postgres,密码postgres(推荐输入) bin\initdb -U postgres -A password -E utf8 -W -D .\data REM 启动数据库服务 bin\pg_ctl -o "-F -p 5432" -D ".\data" start REM 自定义数据库名:<db_name> set DB_NAME=<db_name> bin\createdb -E UTF-8 -O postgres -U postgres %DB_NAME% REM 至此数据库<db_name>已经可以通过用户postgres密码postgres访问了 REM 其他功能 REM REM 备份数据库,把数据库<db_name>输出为一个备份文件<db_name>.backup bin\pg_dump -h 127.0.0.1 -p 5432 -U postgres --file=%DB_NAME%.backup -Ft -b %DB_NAME% REM 恢复备份数据库 bin\pg_restore -h 127.0.0.1 -p 5432 -U postgres -d <db_name> --file=<db_name>.backup REM 删除数据库 bin\dropdb -U postgres %DB_NAME%