{"record":{"id":"69396324ce808121","repo":"vitessio/vitess","slug":"couldn-t-read-my-cnf-file-v","errorCode":null,"errorMessage":"couldn't read my.cnf file: %v","messagePattern":"couldn't read my\\.cnf file: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/mysqlctl/cmd.go","lineNumber":61,"sourceCode":"\tif err := mycnf.RandomizeMysqlServerID(); err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"couldn't generate random MySQL server_id: %v\", err)\n\t}\n\tif mysqlSocket != \"\" {\n\t\tmycnf.SocketFile = mysqlSocket\n\t}\n\n\tdbconfigs.GlobalDBConfigs.InitWithSocket(mycnf.SocketFile, collationEnv)\n\treturn NewMysqld(&dbconfigs.GlobalDBConfigs), mycnf, nil\n}\n\n// OpenMysqldAndMycnf returns a Mysqld and a Mycnf object to use for working with a MySQL\n// installation that already exists. The Mycnf will be built based on the my.cnf file\n// of the MySQL instance.\nfunc OpenMysqldAndMycnf(tabletUID uint32, collationEnv *collations.Environment) (*Mysqld, *Mycnf, error) {\n\t// We pass a port of 0, this will be read and overwritten from the path on disk\n\tmycnf, err := ReadMycnf(NewMycnf(tabletUID, 0), 0)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"couldn't read my.cnf file: %v\", err)\n\t}\n\n\tdbconfigs.GlobalDBConfigs.InitWithSocket(mycnf.SocketFile, collationEnv)\n\treturn NewMysqld(&dbconfigs.GlobalDBConfigs), mycnf, nil\n}\n","sourceCodeStart":43,"sourceCodeEnd":67,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/mysqlctl/cmd.go#L43-L67","documentation":"OpenMysqldAndMycnf reads the existing tablet's my.cnf from disk (ReadMycnf) to rebuild the Mycnf struct; a missing or unreadable/unparseable my.cnf produces this wrapped error. It is used by commands operating on an already-initialized MySQL instance.","triggerScenarios":"Running mysqlctl commands (shutdown, start, reinit-config, teardown) for a tabletUID whose my.cnf does not exist, was deleted, or is corrupt.","commonSituations":"Wrong tablet UID passed on the command line, tablet never initialized (no prior `mysqlctl init`), my.cnf deleted by cleanup scripts, disk/permission problems.","solutions":["Verify the tablet UID and that `<vtdataroot>/vt_<uid>/my.cnf` exists.","Run `mysqlctl init` first if the instance was never initialized.","Restore the my.cnf file (from backup or re-run init-config) if deleted.","Check file permissions/readability for the mysqlctl user."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"mycnfPath := filepath.Join(vtdataroot, fmt.Sprintf(\"vt_%d\", tabletUID), \"my.cnf\")\nif _, err := os.Stat(mycnfPath); os.IsNotExist(err) {\n\treturn fmt.Errorf(\"run mysqlctl init first; %s missing\", mycnfPath)\n}","typeGuard":null,"tryCatchPattern":"m, mycnf, err := mysqlctl.OpenMysqldAndMycnf(uid, collationEnv)\nif err != nil && strings.Contains(err.Error(), \"couldn't read my.cnf file\") {\n\t// verify tablet UID or re-init the instance\n}","preventionTips":["Double-check tablet UID arguments","Never delete my.cnf under vt_<uid> without re-init","Run init before start/shutdown/teardown commands"],"tags":["mysql","mycnf","initialization"],"backgroundTag":"mycnf-file-missing","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}