postgresql中通过设置环境变量绕过手工输入口令

postgresql中,通过设置环境变量,可以利用命令行做很多事情,包括绕过手工输入口令的环节。原说明书摘录如下,供大家参阅:

注意,因为批处理里存储了账号和口令,需要设置好批处理的访问权限,避免安全隐患。

33.14. Environment Variables

The following environment variables can be used to select default connection parameter values, which will be used by PQconnectdbPQsetdbLogin and PQsetdb if no value is directly specified by the calling code. These are useful to avoid hard-coding database connection information into simple client applications, for example.

  • PGHOST behaves the same as the host connection parameter.

  • PGHOSTADDR behaves the same as the hostaddr connection parameter. This can be set instead of or in addition to PGHOST to avoid DNS lookup overhead.

  • PGPORT behaves the same as the port connection parameter.

  • PGDATABASE behaves the same as the dbname connection parameter.

  • PGUSER behaves the same as the user connection parameter.

  • PGPASSWORD behaves the same as the password connection parameter. Use of this environment variable is not recommended for security reasons, as some operating systems allow non-root users to see process environment variables via ps; instead consider using a password file (see Section 33.15).

  • PGPASSFILE behaves the same as the passfile connection parameter.

  • PGCHANNELBINDING behaves the same as the channel_binding connection parameter.

  • PGSERVICE behaves the same as the service connection parameter.

  • PGSERVICEFILE specifies the name of the per-user connection service file. If not set, it defaults to ~/.pg_service.conf (see Section 33.16).

  • PGOPTIONS behaves the same as the options connection parameter.

  • PGAPPNAME behaves the same as the application_name connection parameter.

  • PGSSLMODE behaves the same as the sslmode connection parameter.

  • PGREQUIRESSL behaves the same as the requiressl connection parameter. This environment variable is deprecated in favor of the PGSSLMODE variable; setting both variables suppresses the effect of this one.

  • PGSSLCOMPRESSION behaves the same as the sslcompression connection parameter.

  • PGSSLCERT behaves the same as the sslcert connection parameter.

  • PGSSLKEY behaves the same as the sslkey connection parameter.

  • PGSSLROOTCERT behaves the same as the sslrootcert connection parameter.

  • PGSSLCRL behaves the same as the sslcrl connection parameter.

  • PGREQUIREPEER behaves the same as the requirepeer connection parameter.

  • PGSSLMINPROTOCOLVERSION behaves the same as the ssl_min_protocol_version connection parameter.

  • PGSSLMAXPROTOCOLVERSION behaves the same as the ssl_max_protocol_version connection parameter.

  • PGGSSENCMODE behaves the same as the gssencmode connection parameter.

  • PGKRBSRVNAME behaves the same as the krbsrvname connection parameter.

  • PGGSSLIB behaves the same as the gsslib connection parameter.

  • PGCONNECT_TIMEOUT behaves the same as the connect_timeout connection parameter.

  • PGCLIENTENCODING behaves the same as the client_encoding connection parameter.

  • PGTARGETSESSIONATTRS behaves the same as the target_session_attrs connection parameter.

The following environment variables can be used to specify default behavior for each PostgreSQL session. (See also the ALTER ROLE and ALTER DATABASE commands for ways to set default behavior on a per-user or per-database basis.)

  • PGDATESTYLE sets the default style of date/time representation. (Equivalent to SET datestyle TO ....)

  • PGTZ sets the default time zone. (Equivalent to SET timezone TO ....)

  • PGGEQO sets the default mode for the genetic query optimizer. (Equivalent to SET geqo TO ....)

Refer to the SQL command SET for information on correct values for these environment variables.

The following environment variables determine internal behavior of libpq; they override compiled-in defaults.

  • PGSYSCONFDIR sets the directory containing the pg_service.conf file and in a future version possibly other system-wide configuration files.

  • PGLOCALEDIR sets the directory containing the locale files for message localization.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值