如何在 Windows 上只安装 PostgreSQL 的客户端工具?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33854798/
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
How do I install just the client tools for PostgreSQL on Windows?
提问by Paul Moore
I have a PostgreSQL database on a Linux system that I want to access from my Windows PC. But the only Windows binaries I have been able to find are the full installer, which includes the database server and client.
我在 Linux 系统上有一个 PostgreSQL 数据库,我想从我的 Windows PC 访问它。但我能找到的唯一 Windows 二进制文件是完整的安装程序,其中包括数据库服务器和客户端。
Is it possible to get a client-only Windows binary install for PostgreSQL from anywhere?
是否可以从任何地方获得 PostgreSQL 的仅客户端 Windows 二进制安装?
(To clarify, I want the standard PostgreSQL client, psql - not a GUI client or independent tool).
(澄清一下,我想要标准的 PostgreSQL 客户端 psql - 而不是 GUI 客户端或独立工具)。
采纳答案by a_horse_with_no_name
Unfortunately there is no real client "only" installer.
不幸的是,没有真正的客户端“唯一”安装程序。
What you can do, is to download the ZIP archive of the complete Postgres binaries:
您可以做的是下载完整 Postgres 二进制文件的 ZIP 存档:
http://www.enterprisedb.com/products-services-training/pgbindownload
http://www.enterprisedb.com/products-services-training/pgbindownload
and then remove the "server" part from it.
然后从中删除“服务器”部分。
When you unzip it, you get the following directories:
解压后,会得到以下目录:
bin doc include lib pgAdmin III share StackBuilder symbols
You can remove the doc
, include
, pgAdmin III
, StackBuilder
and symbols
directories. As far as I can tell (but I am not sure) the client also doesn't need the share
or lib
directories, but you would need to test that. So that leaves only the bin
directory.
您可以删除doc
,include
,pgAdmin III
,StackBuilder
和symbols
目录。据我所知(但我不确定)客户端也不需要share
orlib
目录,但您需要对其进行测试。所以只留下bin
目录。
I think the share
directory could be needed for localized error messages in psql
but I'm not sure about that.
我认为share
本地化错误消息可能需要该目录,psql
但我不确定。
Inside the bin
directory you can essentially remove all .exe files (except psql.exe
of course). You can also remove all wx*.dll
files, they are only needed for pgAdmin. The libxml2.dll
and libxslt.dll
are also only needed for the server.
在bin
目录中,您基本上可以删除所有 .exe 文件(psql.exe
当然除外)。您也可以删除所有wx*.dll
文件,只有 pgAdmin 需要它们。该libxml2.dll
和libxslt.dll
也仅需要服务器。
If you do want some of the other client tools, you might want to keep
如果您确实需要其他一些客户端工具,您可能希望保留
- pg_dump.exe
- pg_dumpall.exe
- pg_restore.exe
- pg_dump.exe
- pg_dumpall.exe
- pg_restore.exe
One drawback of this approach is that this requires the Visual C++ Redistributable to be installed. But you can overcome that as well by simply putting the MSVCR120.DLL
from some computer where it is installed into the bin
directory.
这种方法的一个缺点是需要安装 Visual C++ Redistributable。但是您也可以通过简单地将MSVCR120.DLL
来自某些计算机的安装bin
目录放入目录中来克服这个问题。
So that leaves you with these files (from the bin
directory) that are required for the psql client:
这样你bin
就可以得到 psql 客户端所需的这些文件(来自目录):
- iconv.dll
- libeay32.dll
- libintl-8.dll
- libpq.dll
- msvcr120.dll
- ssleay32.dll
- zlib1.dll
- psql.exe
- 图标文件
- libeay32.dll
- libintl-8.dll
- 库文件
- msvcr120.dll
- ssleay32.dll
- zlib1.dll
- 执行程序
Of course you can also take all that from an existing Postgres installation without the need to download the ZIP archive.
当然,您也可以从现有的 Postgres 安装中获取所有内容,而无需下载 ZIP 存档。
It is obviously not a real installer, but if you put the cleaned up directory into a ZIP file, you can distribute that and whoever needs it just unzips the archive. Personally I find unzip
to be the best "installer" anyway (I also use that to install the Postgres server, the Windows installer just has too many quirks)
它显然不是真正的安装程序,但是如果您将清理后的目录放入 ZIP 文件中,您可以分发它,任何需要它的人只需解压缩存档即可。我个人认为unzip
无论如何都是最好的“安装程序”(我也用它来安装 Postgres 服务器,Windows 安装程序有太多的怪癖)
回答by Dmitrii Mikhailov
Actually there are client CLI tools in pgAdmin. All you need is just to install it on your Windows machine from https://www.postgresql.org/download/windows/.
实际上 pgAdmin 中有客户端 CLI 工具。您所需要的只是从https://www.postgresql.org/download/windows/将它安装在您的 Windows 机器上。
Then you'll be able to find those tools in folder like C:\Program Files (x86)\pgAdmin III\1.22
or C:\Program Files (x86)\pgAdmin 4\v2\runtime
, depends on the pgAdmin version you have installed.
然后,您将能够在C:\Program Files (x86)\pgAdmin III\1.22
或 等文件夹中找到这些工具C:\Program Files (x86)\pgAdmin 4\v2\runtime
,具体取决于您安装的 pgAdmin 版本。
回答by Rick
I realize this is an older question, but when I used the Windows installer for the latest version of Postgres (10.4), it gave me the option to install just the command line tools. I just unchecked server
and pgadmin
in the installer's window when prompted to choose what I wanted to install.
我意识到这是一个较旧的问题,但是当我将 Windows 安装程序用于最新版本的 Postgres (10.4) 时,它让我可以选择只安装命令行工具。当提示选择我想要安装的内容时,我只是取消选中server
并pgadmin
在安装程序的窗口中。
回答by Geoff
Thanks to everyone who has posted on this thread.
感谢所有在此线程上发帖的人。
For what it's worth, I got psql.exe from PostgreSQL 10.10 working under Windows 10 with just the following files from the zip archive:
值得一提的是,我从 PostgreSQL 10.10 获得了 psql.exe,它在 Windows 10 下工作,只包含 zip 存档中的以下文件:
libcrypto-1_1-x64.dll
libiconv-2.dll
libintl-8.dll
libpq.dll libssl-1_1-x64.dll
psql.exe
libcrypto-1_1-x64.dll
libiconv-2.dll
libintl-8.dll
libpq.dll libssl-1_1-x64.dll
psql.exe
When connecting to AWS Redshift, I got the following error:
连接到 AWS Redshift 时,出现以下错误:
psql: FATAL: invalid value for parameter "client_encoding": "WIN1252"
psql:致命:参数“client_encoding”的无效值:“WIN1252”
I resolved this by running
我通过运行解决了这个问题
set PGCLIENTENCODING=UTF8
I found this solution at https://forums.aws.amazon.com/thread.jspa?messageID=600088
我在https://forums.aws.amazon.com/thread.jspa?messageID=600088找到了这个解决方案
HTH.
哈。