无需安装即可在 Windows 中启动 postgresql 和 pgadmin
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26441873/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
starting postgresql and pgadmin in windows without installation
提问by user3263117
How can I start PostgreSQL and pgAdmin III in windows without installation. I do not have admin rights in a system. so I need to start the application without installing . How can I do that?
如何在不安装的情况下在 Windows 中启动 PostgreSQL 和 pgAdmin III。我在系统中没有管理员权限。所以我需要启动应用程序而不安装 . 我怎样才能做到这一点?
回答by a_horse_with_no_name
- Download the ZIP file from https://www.enterprisedb.com/products-services-training/pgbindownload
- Unzip the archive into a directory of your choice (the archive is created such that unzipping it, it will create a directory
pgsql
with everything else below that) Run
initdb
(this can be found in the subdirectorypgsql\bin
)initdb -D c:\Users\Arthur\pgdata -U postgres -W -E UTF8 -A scram-sha-256
This will create the postgres "data directory" (aka the "cluster") in
c:\Users\Arthur\pgdata
. You need to make sure that the user running this command has full read/write privileges on that directory.-U postgres
creates the superuser aspostgres
,-W
will prompt you for the password of the superuser,-E UTF8
will create the database withUTF-8
encoding and-A md5
enables the password authentication.To start Postgres, run:
pg_ctl -D c:\Users\Arthur\pgdata start
this has(!) to be done as the user who ran
initdb
to avoid any problems with the access to the data directory.To shutdown Postgres, run:
pg_ctl -D c:\Users\Arthur\pgdata stop
psql.exe
(the command line client) is located in thebin
directory. Starting with Postgres 9.6 the pgAdmin executablepgAdmin4.exe
is located in the sub-directory"pgAdmin 4\bin"
.Optionally create a Windows service to automatically run Postgres (mustbe run using a Windows administrator account)
pg_ctl register -N postgresql -D c:\Users\Arthur\pgdata stop
- 从https://www.enterprisedb.com/products-services-training/pgbindownload下载 ZIP 文件
- 将存档解压缩到您选择的目录中(创建存档时解压缩它,它将创建一个目录,
pgsql
其中包含其他所有内容) 运行
initdb
(这可以在子目录中找到pgsql\bin
)initdb -D c:\Users\Arthur\pgdata -U postgres -W -E UTF8 -A scram-sha-256
这将在
c:\Users\Arthur\pgdata
. 您需要确保运行此命令的用户对该目录具有完全读/写权限。-U postgres
创建超级用户 aspostgres
,-W
将提示您输入超级用户的密码,-E UTF8
将使用UTF-8
编码创建数据库并-A md5
启用密码验证。要启动 Postgres,请运行:
pg_ctl -D c:\Users\Arthur\pgdata start
这必须(!)作为运行的用户来完成,
initdb
以避免访问数据目录时出现任何问题。要关闭 Postgres,请运行:
pg_ctl -D c:\Users\Arthur\pgdata stop
psql.exe
(命令行客户端)位于bin
目录中。从 Postgres 9.6 开始,pgAdmin 可执行文件pgAdmin4.exe
位于子目录中"pgAdmin 4\bin"
。可以选择创建一个 Windows 服务来自动运行 Postgres(必须使用 Windows 管理员帐户运行)
pg_ctl register -N postgresql -D c:\Users\Arthur\pgdata stop
回答by Chinmayee Seth
Thank you. This worked for me. But, i was getting error while starting psql.exe
谢谢你。这对我有用。但是,我在启动 psql.exe 时出错
The error was "psql: FATAL : role [user] does not exist."
错误是“psql:致命:角色 [用户] 不存在。”
To resolve this, i followed the below steps:
为了解决这个问题,我按照以下步骤操作:
- Be on the same folder path (where you have initdb.exe) i.e. source-folder/pgsql/bin
- Run "psql -U postgres". This will ask for password.
- Now enter the password that was set during postgres intialization. This will open the psql command prompt.
- 位于相同的文件夹路径(您有 initdb.exe 的位置),即 source-folder/pgsql/bin
- 运行“psql -U postgres”。这将要求输入密码。
- 现在输入在 postgres 初始化期间设置的密码。这将打开 psql 命令提示符。
Hope this helps.. :)
希望这可以帮助.. :)
回答by Vikram S
I tried above method its working fine, but when i tried to connect it via JDBC i used to get
我试过上面的方法它工作正常,但是当我尝试通过 JDBC 连接它时,我曾经得到
"The authentication type 10 is not supported. Check that you have configured the pg_hba.conf file to include the client's IP address or subnet, and that it is using an authentication scheme supported by the driver."
“不支持身份验证类型 10。检查您是否已将 pg_hba.conf 文件配置为包含客户端的 IP 地址或子网,并且它正在使用驱动程序支持的身份验证方案。”
This happens because scram-sha-256has some issue(refer here), i couldn't understand in depth, so i changed it to md5, All started to work smoothly.hope it helps
发生这种情况是因为scram-sha-256有一些问题(请参阅此处),我无法深入理解,所以我将其更改为 md5,一切开始顺利。希望对您有所帮助
.\initdb -D D:\database\dbdata -U postgres -W -E UTF8 -A md5
.\initdb -DD:\database\dbdata -U postgres -W -E UTF8 -A md5