-
Hey GORM community, I’m encountering an issue when trying to connect to my MySQL database using GORM. The error message I receive is:
Here's what I am trying to do: package config
import (
"log"
"gorm.io/driver/mysql"
"gorm.io/gorm"
)
var DB *gorm.DB
func InitDB() {
connectionString := GetConnectionString()
var err error
DB, err = gorm.Open(mysql.Open(connectionString), &gorm.Config{})
if err != nil {
log.Fatal("Failed to Connect", err)
}
} Go version: 1.22.4 Any insights or suggestions would be greatly appreciated. Thanks in advance for your help! |
Beta Was this translation helpful? Give feedback.
Answered by
blaze-d83
Aug 23, 2024
Replies: 1 comment
-
For anyone on Windows facing this issue, check in your services.msc whether MySQL / MySQL80 is running. If not, then start the service and this issue should be resolved. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
blaze-d83
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
For anyone on Windows facing this issue, check in your services.msc whether MySQL / MySQL80 is running. If not, then start the service and this issue should be resolved.