{"record":{"id":"1c5c7738c918287e","repo":"vitessio/vitess","slug":"timed-out-after-v-waiting-for-the-dba-user-to-hav","errorCode":null,"errorMessage":"timed out after %v waiting for the dba user to have the required permissions","messagePattern":"timed out after (.+?) waiting for the dba user to have the required permissions","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/mysqlctl/mysqld.go","lineNumber":709,"sourceCode":"\t\tconn, connErr := mysql.Connect(ctx, params)\n\t\tif connErr == nil {\n\t\t\tres, fetchErr := conn.ExecuteFetch(\"SHOW GRANTS\", 1000, false)\n\t\t\tconn.Close()\n\t\t\tif fetchErr != nil {\n\t\t\t\tlog.Error(fmt.Sprintf(\"Error running SHOW GRANTS - %v\", fetchErr))\n\t\t\t}\n\t\t\tif fetchErr == nil && res != nil && len(res.Rows) > 0 && len(res.Rows[0]) > 0 {\n\t\t\t\tprivileges := res.Rows[0][0].ToString()\n\t\t\t\t// In MySQL 8.0, all the privileges are listed out explicitly, so we can search for SUPER in the output.\n\t\t\t\t// In MySQL 5.7, all the privileges are not listed explicitly, instead ALL PRIVILEGES is written, so we search for that too.\n\t\t\t\tif strings.Contains(privileges, \"SUPER\") || strings.Contains(privileges, \"ALL PRIVILEGES\") {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tselect {\n\t\tcase <-timer.C:\n\t\t\treturn fmt.Errorf(\"timed out after %v waiting for the dba user to have the required permissions\", waitTime)\n\t\tdefault:\n\t\t\ttime.Sleep(100 * time.Millisecond)\n\t\t}\n\t}\n}\n\n// wait is the internal version of Wait, that takes credentials.\nfunc (mysqld *Mysqld) wait(ctx context.Context, cnf *Mycnf, params *mysql.ConnParams) error {\n\tlog.Info(fmt.Sprintf(\"Waiting for mysqld socket file (%v) to be ready...\", cnf.SocketFile))\n\n\tfor {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn errors.New(\"deadline exceeded waiting for mysqld socket file to appear: \" + cnf.SocketFile)\n\t\tdefault:\n\t\t}\n\n\t\t_, statErr := os.Stat(cnf.SocketFile)","sourceCodeStart":691,"sourceCodeEnd":727,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/mysqlctl/mysqld.go#L691-L727","documentation":"WaitForDBAGrants polls until the dba user has the grants vitess requires (checked via the app config); if the waitTime timer fires first it gives up with this timeout error. It is thrown because a grant operation external to vitess (e.g. init db sql or an operator script) hasn't taken effect in time.","triggerScenarios":"Calling Mysqld.WaitForDBAGrants after startup/init when SHOW GRANTS for the dba user still lacks required privileges after waitTime elapses (default from -wait_for_dba_grants / 30s-style defaults).","commonSituations":"Init DB SQL granting permissions runs slowly or failed; replication-lag or slow cold-start mysqld; dba user created with wrong host pattern (`dba'@'localhost` vs `%`) so grants don't match; misconfigured dba user credentials in my.cnf.","solutions":["Connect as root and run `SHOW GRANTS FOR CURRENT_USER()` as the dba user to see what's missing","Apply the required GRANT statements manually or fix the init_db.sql script","Increase the wait timeout flag if mysqld startup is legitimately slow","Verify the dba user host pattern matches how vitess connects (localhost vs %)"],"exampleFix":"// before: dba user without proper grants\nCREATE USER 'vt_dba'@'localhost';\n// after\nCREATE USER 'vt_dba'@'localhost';\nGRANT ALL ON *.* TO 'vt_dba'@'localhost' WITH GRANT OPTION;\nFLUSH PRIVILEGES;","handlingStrategy":"retry","validationCode":"// Verify grants before waiting\nout, err := runSQL(\"SHOW GRANTS FOR 'vt_dba'@'localhost'\")\nif err != nil || !strings.Contains(out, \"ALL PRIVILEGES\") {\n    return errors.New(\"dba user lacks required grants; fix init_db.sql first\")\n}","typeGuard":null,"tryCatchPattern":"if err := mysqld.WaitForDBAGrants(ctx); err != nil && strings.Contains(err.Error(), \"timed out\") {\n    // re-apply grants then retry once with a longer window\n}","preventionTips":["Include the full dba GRANT statements in init_db.sql","Match the dba user's host pattern to vitess's connection host","Increase the grants wait timeout on slow-starting instances","Verify grants after every manual user refactor"],"tags":["mysql","grants","timeout","mysqlctl"],"backgroundTag":"dba-grants-timeout","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}