admin管理员组文章数量:1665605
CentOS
登录到官方网站( https://www.postgresql/download/linux/redhat/ ),找到需要安装的版本和操作系统版本,并安装官方源:
上图中给出的是安装PG服务端的命令,若仅需要安装PG客户端,那么在安装源之后,执行以下指令即可:
yum install -y https://download.postgresql/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum install postgresql13 -y
#我这里安装的PG13版本的源,所以指定下版本,若不指定版本则会安装9.2版本
Ubuntu
执行如下安装命令:
sudo apt-get update
sudo apt-get install postgresql-client
Debian
执行如下安装命令:
sudo apt-get update
sudo apt-get install postgresql-client
Windows安装方法参看:
https://www.postgresql/download/windows/
macOS
在macOS下有多种安装方法,主要如下所示:
方法1: 使用brew安装整体的包
macOS下PostgreSQL只提供了postgres的包,可以通过如下命令安装全体的包,执行命令:brew install postgres
方法2: 使用官方的安装包
使用官方的安装包,一路Next就可以安装完成了,下载地址为:
https://www.postgresql/download/macosx/
方法3: 使用Postgres.app
Postgres.app把相关需要的内容都进行了打包,下载地址为:
https://postgresapp/downloads.html
方法4: 使用libpq
如果你只希望安装客户端,那可以考虑使用libpq来代替,安装方式如下所示:
1、环境确认
liumiaocn:~ liumiao$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.15.6
BuildVersion: 19G73
liumiaocn:~ liumiao$
2、brew update
确认brew状态,使用如下命令:
liumiaocn:~ liumiao$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!
Warning: The following directories do not exist:
/usr/local/sbin
You should create these directories and change their ownership to your account.
sudo mkdir -p /usr/local/sbin
sudo chown -R $(whoami) /usr/local/sbin
liumiaocn:~ liumiao$
3、执行brew update
liumiaocn:~ liumiao$ brew update
==> Downloading https://homebrew.bintray/bottles-portable-ruby/portable-ruby-2.6.3_2.yosemite.bottle.tar.gz
################################################################################################################################# 100.0%
==> Pouring portable-ruby-2.6.3_2.yosemite.bottle.tar.gz
==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
https://docs.brew.sh/Analytics
No analytics have been recorded yet (or will be during this `brew` run).
Updated 3 taps (homebrew/core, homebrew/cask and homebrew/services).
...省略
gambit podman youview
ghostlab pokemon-trading-card-game-online
liumiaocn:~ liumiao$
4、brew install libpq
liumiaocn:~ liumiao$ brew install libpq
==> Downloading https://homebrew.bintray/bottles/openssl%401.1-1.1.1g.catalina.bottle.tar.gz
...省略
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
liumiaocn:~ liumiao$
5、结果确认
本文安装的内容可以在如下目录下查询到
liumiaocn:bin liumiao$ pwd
/usr/local/Cellar/libpq/12.4/bin
liumiaocn:bin liumiao$ ls
clusterdb initdb pg_ctl pg_resetwal pg_waldump
createdb pg_archivecleanup pg_dump pg_restore pgbench
createuser pg_basebackup pg_dumpall pg_rewind psql
dropdb pg_checksums pg_isready pg_test_fsync reindexdb
dropuser pg_config pg_receivewal pg_test_timing vacuumdb
ecpg pg_controldata pg_recvlogical pg_upgrade
liumiaocn:bin liumiao$
可以看到已经有psql等命令了,所以只需要将bin追加至PATH中即可。也可每次都带上全路径进行访问。
liumiaocn:bin liumiao$ /usr/local/Cellar/libpq/12.4/bin/psql --version
psql (PostgreSQL) 12.4
liumiaocn:bin liumiao$
本文标签: 客户端系统Linuxpostgresql
版权声明:本文标题:Linux系统中PostgreSQL客户端的安装 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dongtai/1730050635a1220769.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论