无法连接到 azure PostresSQL 数据库 用户名应采用 <用户名@主机名> 格式

无法连接到 azure postressql 数据库 - 用户名应采用 用户名@主机名 格式

问题内容

我无法连接到 golang 应用程序中的 azure postgresql 数据库

错误消息:

fatal: invalid username specified. please check the username and retry connection. the username should be in format. (sqlstate 28000))

登录后复制

我的用户名中没有@。

我使用 gorm 作为 orm 并像这样连接

dburl := fmt.sprintf("postgres://%s:%s@%s:5432/%s", dbuser, dbpass, dbhost, dbname)
db, err := gorm.open(postgres.open(dburl), &gorm.config{})

登录后复制

我的变量看起来像这样

postgres_password="password!"
db_host="some-url-with-dashes.postgres.database.azure.com"
app_port="8080"
postgres_user="postgresuser"
db_name="file"

登录后复制

我的代码确实看到了它们并正确创建了 dburl ,如下所示:

postgres://postgresuser:[email protected]:5432/file

登录后复制

我已尝试更改用户名和密码

正确答案

您必须配置参数db_user_namespaceon。不要这样做。

以上就是无法连接到 azure PostresSQL 数据库 - 用户名应采用 格式的详细内容,更多请关注每日运维网(www.mryunwei.com)其它相关文章!