英文:
Cannot connect to azure PostresSQL database - The Username should be in <username@hostname> format
问题
我无法连接到 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:password!@some-url-with-dashes.postgres.database.azure.com:5432/file
我已尝试更改用户名和密码。
英文:
I cannot connect to an Azure PostgreSQL database in a Golang application
Error message :
FATAL: Invalid Username specified. Please check the Username and retry connection. The Username should be in <username@hostname> format. (SQLSTATE 28000))
I do not have an @ in my username.
I am using gorm as a ORM and connecting like this
dbUrl := fmt.Sprintf("postgres://%s:%s@%s:5432/%s", dbUser, dbPass, dbHost, dbName)
db, err := gorm.Open(postgres.Open(dbUrl), &gorm.Config{})
My variables look like this
POSTGRES_PASSWORD="password!"
DB_HOST="some-url-with-dashes.postgres.database.azure.com"
APP_PORT="8080"
POSTGRES_USER="postgresuser"
DB_NAME="file"
My code does see them and correctly creates dbUrl
like :
postgres://postgresuser:password!@some-url-with-dashes.postgres.database.azure.com:5432/file
I have tried changing the username and password
答案1
得分: 1
你必须将参数db_user_namespace
配置为on
。不要这样做。
英文:
You must have configured the parameter db_user_namespace
to on
. Don't do that.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论