devlake-go mysql connection failure
Closed this issue · 1 comments
Description
devlake-go
fails to connect to devlake
database. The problem appears to be related to the value of the default_authentication_plugin
MySQL server parameter.
The MySQL server hosting our devlake
database runs with the default_authentication_plugin
set to mysql_native_password
. In this case, devlake-go
fails to connect no matter whether the devlake
user' password is created with the native
or caching_sha2_password
plugin.
The connection can be established, however, when I recompile the client with the mysql config parameter AllowNativePasswords
set to true
.
Expected behavior
❯ DEVLAKE_DBUSER=devlake DEVLAKE_DBPASS=.... make run-api
--> Compiling the project
go build -ldflags "-X main.gitsha=ec5c1ab -X main.compiled=1709134032" -o bin/opendora-api api/main.go
--> Running the OpenDORA API
2024/02/28 16:27:15 connected to DevLake database
Actual Behavior
❯ DEVLAKE_DBUSER=devlake DEVLAKE_DBPASS=... make run-api
--> Compiling the project
go build -ldflags "-X main.gitsha=ec5c1ab -X main.compiled=1709134118" -o bin/opendora-api api/main.go
--> Running the OpenDORA API
[mysql] 2024/02/28 16:28:39 connector.go:95: could not use requested auth plugin 'mysql_native_password': this user requires mysql native password authentication.
2024/02/28 16:28:39 this user requires mysql native password authentication.
exit status 1
make: *** [Makefile:105: run-api] Error 1
Reproduction steps
- set up devlake with MySQL 8.* and the server parameter
default_authentication_plugin
set tomysql_native_password
- follow
devlake-go
README, executemake run-api
with your devlake database details devlake-go
fails to connect to the database
The following modification to devlake-go/api/sql_client/client.go
fixes the connection issue for this particular case:
diff --git a/devlake-go/api/sql_client/client.go b/devlake-go/api/sql_client/client.go
index a56eca4..ea359ad 100644
--- a/devlake-go/api/sql_client/client.go
+++ b/devlake-go/api/sql_client/client.go
@@ -34,6 +34,7 @@ func (client Client) connectToDatabase() {
Net: "tcp",
Addr: os.Getenv("DEVLAKE_DBADDRESS"),
DBName: os.Getenv("DEVLAKE_DBNAME"),
+ AllowNativePasswords: true,
}
var err error
Your Environment
- MySQL 8.0.35
Context of the bug
No response
Have you spent some time to check if this bug has been raised before?
- I checked and didn't find similar issue
Are you willing to submit PR?
None
Hi @jtatarik,
Thanks for the thorough explanation of your issue and good catch! For now, I feel like we can implement your modification 1:1. so I will create a PR with the changes 😃