The basic process of Mysqld_safe script execution:
1, find Basedir and Ledir.
2, find DataDir and my.cnf.
3, to MY.CNF do some checks, specific check which options please see the comments in the attachment.
4, parse the group [mysqld] and [Mysqld_safe] in my.cnf and merge with the commands entered in the terminal.
5, call the Parse_arguments function to resolve all the parameters passed by the user ($@).
6, the System log and error log judgment and the corresponding processing can refer to the appendix of the comments, and options--err-log parameters of the assignment.
7, the choice of--user,--pid-file,--socket and--port processing and assigning value, to ensure that when the startup if not given these parameters it will also have a value.
8, start mysqld.
A will determine if a process number exists at startup, and if so, record "A mysqld process already exists" in the error log and exit.
(b) If it does not exist, delete the process file, if it is not deleted, then in the error log record "Fatal Error:can ' t remove the PID file" and exit.
9. Check the table at startup. Setting Key_buffer and Sort_buffer when checking the table at startup can increase speed and reduce disk space usage. You can also use the Myisam-recover option to recover an error MyISAM table.
10, if you do not have any parameters to start, then it will choose some specific parameters to start, the specific parameters please see the attachment note.
11, if the server shuts down unexpectedly, then will restart.
Finally, take three steps to sum up
Check the Environment
Check configuration options
Handling after startup and startup
Summary: Choose the benefits of Mysqld_safe startup. The
1, Mysqld_safe adds some security features, such as restarting the server when an error occurs and writing Run-time information to the error log file.
2, if any of the options are specific to Mysqld_safe startup, you can specify that if you specify in the configuration file that you want to put in the [Mysqld_safe] group, the other groups cannot be parsed correctly. The
3, Mysqld_safe boot can specify the kernel file size ulimit-c $core _file_size and the number of open files Ulimit-n $size.
4, the MySQL program first check the environment variables, and then check the configuration file, and finally check the terminal options, indicating that the terminal specified options the highest priority.