我通常需要在运行在azure上的postgres上创建一个额外的用户:
create user myfineuser with password 'myfinepassword';
grant connect on database myfinedatabase to myfineuser;
但是当我然后尝试使用azure连接到数据库时
psql "host=myfinehost.postgres.database.azure.com port=5432 \
dbname=myfinedatabase user=myfineuser password=myfinepassword sslmode=require"
我确实收到
psql: FATAL: Invalid Username specified. Please check the Username and retry connection. The
Username should be in <username@hostname> format.
我不满意如何在sql语句中指定user @ host来创建用户
myfineuser@myfinehost, 'myfineuser@myfinehost', .... all these permutations do result in a syntax error
我该如何使用psql。本文仅讨论用户,而不是如何指定user @ host https://docs.microsoft.com/da-dk/azure/postgresql/howto-create-users#how-to-create-database-users-in-azure-database-for-postgresql
答案 0 :(得分:0)
简单的解决方法:
create user myfineuser with password 'myfinepassword';
grant connect on database myfinedatabase to myfineuser;
然后在psql中:
psql "host=myfinehost.postgres.database.azure.com port=5432 \
dbname=myfinedatabase user=myfineuser@myfinehost password=myfinepassword sslmode=require"
在psql连接字符串中注意 myfineuser @ myfinehost 。这是隐式的