Gin web service cannot connect mysql service

I tried to build a web service made with gin + gorm + mysql.
To use mysql, I build mysql service too, then I changed gorm connection setting like below.

dsn = fmt.Sprintf("%s:%s@tcp(mysql-xxxx:3306)/%s?charset=utf8&parseTime=True&loc=Local", user, pw, db_name)
dialector := mysql.Open(dsn)
	var err error
	if Db, err = gorm.Open(dialector); err != nil {
		connect(dialector, 100)

mysql-xxxx is tcp information shown in mysql service page.
I’ve created the mysql user and database via SSH.

But the web service failed deployment.
logs are

[error] failed to initialize database, got error Error 1045 (28000): Access denied for user 'testuser'@'' (using password: YES)

What should I fix??

Hello there,

This error would mean that your connection details are incorrect or the MySQL user settings don’t allow the connection. However, in your specific case, it looks like you have modified your services environment outside of the blueprint used, which may be causing this to occur. To help us discuss the specific details of your services configuration, can you please open a ticket from the Render dashboard.


1 Like

I confirmed logs after some hours, the log output changed.

“failed to initialize database, got error MySQL server does not support required protocol 41+”

This message seems to appear in mysql8, so I thought the version cause problems.
I built a mysql5 private service, then connected gin web service to it.
The build of Gin application finished successfully.

The problem was solved. Thanks

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.