欢迎光临
我们一直在努力

无法连接到 azure PostresSQL 数据库 - 用户名应采用 格式

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

问题内容

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

错误消息:

fatal: invalid username specified. please check the username and retry connection. the username should be in <username@hostname> 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。不要这样做。

赞(0) 打赏
未经允许不得转载:码农资源网 » 无法连接到 azure PostresSQL 数据库 - 用户名应采用 格式
分享到

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续提供更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫打赏

微信扫一扫打赏

登录

找回密码

注册