<img src="D:pic/2025-03-01/https://cdn.chuangxiangniao.com/2025/03/20250301102359704.jpg" alt="无法连接到 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_namespace 到 on。不要这样做。
以上就是无法连接到 azure PostresSQL 数据库 – 用户名应采用 格式的详细内容,更多请关注【创想鸟】其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。
发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2360864.html