Home > Backend Development > Golang > Unable to connect to azure PostresSQL database - username should be in the format

Unable to connect to azure PostresSQL database - username should be in the format

WBOY
Release: 2024-02-05 21:51:11
forward
865 people have browsed it

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

Question content

I cannot connect to azure postgresql database in golang application

wrong information:

fatal: invalid username specified. please check the username and retry connection. the username should be in <username@hostname> format. (sqlstate 28000))
Copy after login

There is no @ in my username.

I use gorm as orm and connect like this

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

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"
Copy after login

My code does see them and creates dburl correctly, like this:

postgres://postgresuser:[email&#160;protected]:5432/file
Copy after login

I have tried changing the username and password


Correct answer


You must configure the parameters db_user_namespace to on. Do not do this.

The above is the detailed content of Unable to connect to azure PostresSQL database - username should be in the format . For more information, please follow other related articles on the PHP Chinese website!

source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template