Amazon redshift 我们可以在没有密码的情况下通过linux shell脚本连接amazon redshift吗?

Amazon redshift 我们可以在没有密码的情况下通过linux shell脚本连接amazon redshift吗?,amazon-redshift,Amazon Redshift,团队, 我使用的是亚马逊红移(8.0.2.)。连接红移集群时,我们可以不使用密码进行连接(这个设置可以在我的本地机器-pg_hba.conf条目中进行) 我已将“md5”设置为提示密码 # IPv4 local connections: host all all 127.0.0.1/32 md5 # IPv6 local connections: host all all ::1/128

团队, 我使用的是亚马逊红移(8.0.2.)。连接红移集群时,我们可以不使用密码进行连接(这个设置可以在我的本地机器-pg_hba.conf条目中进行) 我已将“md5”设置为提示密码

# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
host    all         all         ::1/128               md5
#host    postgres   postgres    <my_ip>      md5
#IPv4本地连接:
托管所有127.0.0.1/32 md5
#IPv6本地连接:
主机所有::1/128 md5
#主机postgres postgres md5
现在我想通过linux服务器连接redshift。在我的shell脚本中,我正在连接redshift并执行我的活动。但是我应该能够连接redhsift(即,我应该能够将密码作为变量传递,并且在连接之后,我应该能够执行我的活动)

你能在这方面指导我吗


Thaks

试试下面的方法,它对我很有用

psql "host=yourhostname port=yourport_no dbname=your_DB_name user=your_user_id password=your_password" -F  --no-align    -c  " Your_SQL_statement"

如果我没有误解您的意思,您希望避免终端询问您的密码。如果是这样,您可以使用环境变量“PGPASSWORD”将您的密码指定给redshift

然后,您可以在命令行中使用“-w”(小写,不含其他内容),以避免询问密码

# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
host    all         all         ::1/128               md5
#host    postgres   postgres    <my_ip>      md5
诸如此类:

export PGPASSWORD=your_password
psql -h your_hostname -d your_databae -U your_user -p your_port -w

对此,我如何连接并从中访问数据。首先我给出连接,然后如何访问sql?