postgreSQL在windows下自动安装并导入sql
@echo off
rem postgre无人值守安装
rem --mode 指示不需要用户干预
rem --unattendedmodeui 指示显示的窗口为最小化的
rem --servicepassword 不指定则与superpassword相同
rem --superpassword 设置超级用户postgres的密码为mywind
rem --servicename postgreSQL默认安装的服务名为postgreSQL-9.3, 这里稍微区别一下
rem 文档帮助参见https://www.enterprisedb.com/docs/en/9.3/pginstguide/PostgreSQL_Installation_Guide-12.htm#P345_22347
postgresql-9.3.3-1-windows-x64.exe --unattendedmodeui minimal --mode unattended --superpassword "myPasswd" --servicename "postgreSQL"
导入sql文件
sudo -u postgres psql db_name < 'file_path'
psql -h hostname -d databasename -U username -f file.sql
导入backup文件
"C:\Program Files\PostgreSQL\9.3\bin\pg_restore.exe" -U root -C ffdb.backup
参见 :
https://www.enterprisedb.com/docs/en/9.3/pginstguide/PostgreSQL_Installation_Guide-12.htm#P345_22347
https://www.enterprisedb.com/docs/en/9.3/pginstguide/PostgreSQL_Installation_Guide-11.htm#P319_19425
https://stackoverflow.com/questions/2732474/restore-a-postgres-backup-file-using-the-command-line