mysqld_safe : Environmentally configured startup script for mysqld
mysqld_safe is the shell script that configures and checks OS settings that are needed or required for mysqld to effectively execute.
When starting mysqld_safe by hand, there are many command options you can pass to it via a customized my.cnf (--defaults-file) or on the command line directly. Any options not understood by mysqld_safe are passed on to mysqld.
In mysqld_safe, there is a loop that launches mysqld executable. Execution in mysqld_safe freezes at that point and waits for mysqld to come back with an exit code.
Here are the possible scenarios for mysqld_safe handling an exit code from mysqld:
- mysqld terminated normally because mysqld was shutdown with
service mysql stop, which makes mysqld_safe terminatemysqladmin shutdown, which makes mysqld_safe terminate
- mysqld terminated abnormally (mysqld crashes or someone run
kill -9 mysqld)- mysqld_safe loops, attempts to start mysqld and mysqld works
- mysqld_safe loops, attempts to start mysqld but fails, mysqld_safe terminates