vitessio/vitess · error
couldn't read my.cnf file: %v
Error message
couldn't read my.cnf file: %v
What it means
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.
Source
Thrown at go/vt/mysqlctl/cmd.go:61
if err := mycnf.RandomizeMysqlServerID(); err != nil {
return nil, nil, fmt.Errorf("couldn't generate random MySQL server_id: %v", err)
}
if mysqlSocket != "" {
mycnf.SocketFile = mysqlSocket
}
dbconfigs.GlobalDBConfigs.InitWithSocket(mycnf.SocketFile, collationEnv)
return NewMysqld(&dbconfigs.GlobalDBConfigs), mycnf, nil
}
// OpenMysqldAndMycnf returns a Mysqld and a Mycnf object to use for working with a MySQL
// installation that already exists. The Mycnf will be built based on the my.cnf file
// of the MySQL instance.
func OpenMysqldAndMycnf(tabletUID uint32, collationEnv *collations.Environment) (*Mysqld, *Mycnf, error) {
// We pass a port of 0, this will be read and overwritten from the path on disk
mycnf, err := ReadMycnf(NewMycnf(tabletUID, 0), 0)
if err != nil {
return nil, nil, fmt.Errorf("couldn't read my.cnf file: %v", err)
}
dbconfigs.GlobalDBConfigs.InitWithSocket(mycnf.SocketFile, collationEnv)
return NewMysqld(&dbconfigs.GlobalDBConfigs), mycnf, nil
}
View on GitHub (pinned to 01a25a7d17)
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.
Defensive patterns
Strategy: validation
Validate before calling
mycnfPath := filepath.Join(vtdataroot, fmt.Sprintf("vt_%d", tabletUID), "my.cnf")
if _, err := os.Stat(mycnfPath); os.IsNotExist(err) {
return fmt.Errorf("run mysqlctl init first; %s missing", mycnfPath)
} Try / catch
m, mycnf, err := mysqlctl.OpenMysqldAndMycnf(uid, collationEnv)
if err != nil && strings.Contains(err.Error(), "couldn't read my.cnf file") {
// verify tablet UID or re-init the instance
} Prevention
- Double-check tablet UID arguments
- Never delete my.cnf under vt_<uid> without re-init
- Run init before start/shutdown/teardown commands
When it happens
Trigger: Running mysqlctl commands (shutdown, start, reinit-config, teardown) for a tabletUID whose my.cnf does not exist, was deleted, or is corrupt.
Common situations: Wrong tablet UID passed on the command line, tablet never initialized (no prior `mysqlctl init`), my.cnf deleted by cleanup scripts, disk/permission problems.
Related errors
- couldn't generate random MySQL server_id: %v
- can't run init-db-sql-file (%v): %v
- no client certs for connection
- unexpected: query ended without no results and no error
- overflow
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/69396324ce808121.
Report an issue: GitHub.