First, MySQL read the configuration file order
Reading order:/etc/my.cnf >/etc/mysql/my.cnf >/usr/etc/my.cnf > ~/.MY.CNF
Command verification:
[[email protected] ~]# MySQL--verbose--help | grep my.cnf
Order of preference, MY.CNF, $MYSQL _tcp_port,
/ETC/MY.CNF/ETC/MYSQL/MY.CNF/USR/ETC/MY.CNF ~/.my.cnf
Second, MySQL startup mode
MySQL is typically started in three different ways: Mysqld, Mysqld_safe, Mysqld_multi (mainly for multi-instance booting)
Three ways of relationship:
First, when we started with service mysqld start or/etc/init.d/mysqld start, we actually used the Mysql.server script, which is called by default Mysqld_ Safe to start mysqld, so usually when we start MySQL, we look at the process and see that there are two processes, mysqld and Mysqld_safe. Both of these are usually single-instance start-up, and of course you can use MYSQLD to start multiple instances. And Mysqld_multi is used to start multiple instances, but also by first calling Mysqld_safe and mysqld to start MySQL.
Third, the MySQL startup principle
The default MySQL service launcher is the Mysql.server,mysql.server program that uses two programs and a function, namely My_print_defaults, Myslqd_safe, and Parse_server_ Arguments
1, My_print_defaults: Read the my.cnf configuration file, output parameters passed to parse_server_arguments, the program read only the parameters in [mysqld] in my.cnf.
2, Parse_server_arguments: This function handles my_print_defaults passed the parameters assigned to--basedir 、--datadir 、--pid-file 、-- Server-startup-timeout
3. The Myslqd_safe:mysqld_safe program calls the MYSQLD program to start the MySQL service, [Mysqld_safe] overrides the parameters in the Mysqld section
4, Mysqld_multi will read [MYSQLD_MUTI],[MYSQLDN] in the configuration file under the parameters, N needs an integer, it is recommended that the port number, the configuration of the section overrides the configuration in the [Mysqld] section
5, when the mysqld process hangs, the mysqld_safe process will monitor and re-start the mysqld.
MySQL read configuration file order, start mode, startup principle