@@ -50,6 +50,21 @@ const (
5050 dbconfigFlags = dbconfigs .DbaConfig
5151)
5252
53+ func initConfigCmd (subFlags * flag.FlagSet , args []string ) error {
54+ subFlags .Parse (args )
55+
56+ // Generate my.cnf from scratch and use it to find mysqld.
57+ mysqld , err := mysqlctl .CreateMysqld (uint32 (* tabletUID ), * mysqlSocket , int32 (* mysqlPort ), dbconfigFlags )
58+ if err != nil {
59+ return fmt .Errorf ("failed to initialize mysql config: %v" , err )
60+ }
61+ defer mysqld .Close ()
62+ if err := mysqld .InitConfig (); err != nil {
63+ return fmt .Errorf ("failed to init mysql config: %v" , err )
64+ }
65+ return nil
66+ }
67+
5368func initCmd (subFlags * flag.FlagSet , args []string ) error {
5469 waitTime := subFlags .Duration ("wait_time" , 5 * time .Minute , "how long to wait for startup" )
5570 initDBSQLFile := subFlags .String ("init_db_sql_file" , "" , "path to .sql file to run after mysql_install_db" )
@@ -189,6 +204,8 @@ type command struct {
189204var commands = []command {
190205 {"init" , initCmd , "[-wait_time=5m] [-init_db_sql_file=]" ,
191206 "Initalizes the directory structure and starts mysqld" },
207+ {"init_config" , initConfigCmd , "" ,
208+ "Initalizes the directory structure, creates my.cnf file, but does not start mysqld" },
192209 {"reinit_config" , reinitConfigCmd , "" ,
193210 "Reinitalizes my.cnf file with new server_id" },
194211 {"teardown" , teardownCmd , "[-wait_time=5m] [-force]" ,
0 commit comments