Remove mysql.server, write state file only after successful startup

[#78600746]