{"record":{"id":"05d8b1fadb24b4d7","repo":"go-sql-driver/mysql","slug":"invalid-dsn-missing-the-slash-separating-the-data","errorCode":null,"errorMessage":"invalid DSN: missing the slash separating the database name","messagePattern":"invalid DSN: missing the slash separating the database name","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dsn.go","lineNumber":31,"sourceCode":"\t\"context\"\n\t\"crypto/rsa\"\n\t\"crypto/tls\"\n\t\"errors\"\n\t\"fmt\"\n\t\"maps\"\n\t\"math/big\"\n\t\"net\"\n\t\"net/url\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n\t\"time\"\n)\n\nvar (\n\terrInvalidDSNUnescaped       = errors.New(\"invalid DSN: did you forget to escape a param value?\")\n\terrInvalidDSNAddr            = errors.New(\"invalid DSN: network address not terminated (missing closing brace)\")\n\terrInvalidDSNNoSlash         = errors.New(\"invalid DSN: missing the slash separating the database name\")\n\terrInvalidDSNUnsafeCollation = errors.New(\"invalid DSN: interpolateParams can not be used with unsafe collations\")\n)\n\n// Config is a configuration parsed from a DSN string.\n// If a new Config is created instead of being parsed from a DSN string,\n// the NewConfig function should be used, which sets default values.\ntype Config struct {\n\t// non boolean fields\n\n\tUser                 string            // Username\n\tPasswd               string            // Password (requires User)\n\tNet                  string            // Network (e.g. \"tcp\", \"tcp6\", \"unix\". default: \"tcp\")\n\tAddr                 string            // Address (default: \"127.0.0.1:3306\" for \"tcp\" and \"/tmp/mysql.sock\" for \"unix\")\n\tDBName               string            // Database name\n\tParams               map[string]string // Connection parameters\n\tConnectionAttributes string            // Connection Attributes, comma-delimited string of user-defined \"key:value\" pairs\n\tCollation            string            // Connection collation. When set, this will be set in SET NAMES <charset> COLLATE <collation> query\n\tLoc                  *time.Location    // Location for time.Time values","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/go-sql-driver/mysql/blob/03d76c7e07908e255ce62d126d07ede3f2365d86/dsn.go#L13-L49","documentation":"Error \"invalid DSN: missing the slash separating the database name\" thrown in go-sql-driver/mysql.","triggerScenarios":"The DSN string is parsed and no '/' separating the network address part from the database name is found.","commonSituations":"The DSN is malformed, e.g. 'user:pass@tcp(localhost:3306)dbname' instead of 'user:pass@tcp(localhost:3306)/dbname'. Add the '/' before the database name (an empty database name still requires the slash when params follow).","solutions":["Add the '/' separating the network address from the database name, e.g. user:pass@tcp(127.0.0.1:3306)/dbname.","If you do not want a default database, still include the trailing slash: user:pass@tcp(127.0.0.1:3306)/."],"exampleFix":"dsn := \"user:pass@tcp(127.0.0.1:3306)/mydb?parseTime=true\"","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"03d76c7e07908e255ce62d126d07ede3f2365d86","analyzedAt":"2026-08-07T10:39:17.340Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}