分析启动过程
加载配置文件
检查权限
加载表空间
MySQL可以读取的配置文件
--defaults-file 指定只读取该配置文件,不在读取其他配置文件
--defaults-extra-file 指定mysqld在读取完指定的配置文件后,还需要读取用户指定的特殊的配置文件
--print-defaults输出现在mysqld指定的参数
--verbose --help #查看该版本相应的参数
读取配置文件顺序
# mysql -v --help | grep my.cnf
order of preference, my.cnf, $MYSQL_TCP_PORT,
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
PS:只保留一份配置文件即可因为后面的配置文件会覆盖前面的配置文件管理部方便
启动方式
#/path/bin/mysqld –defaults-file=/path/my.cnf &
# ps -ef | grep mysql
mysql 20098 1817 2 03:47 pts/0 00:00:00 mysqld --defaults-file=/etc/my.cnf
# service mysqld start
# /etc/init.d/mysqld start
# ps -ef |grep mysql
root 6432 1 0 02:41 pts/1 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql/mysql_3376/data --pid-file=/data/mysql/mysql_3376/data/mysql.pid
mysql 7511 6432 0 02:41 pts/1 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql/mysql_3376/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/mysql_3376/data/error.log --pid-file=/data/mysql/mysql_3376/data/mysql.pid --socket=/tmp/mysql3376.sock --port=3376
root 7562 3102 0 02:49 pts/1 00:00:00 grep mysql
# mysqld_safe --defaluts-file=/etc/my.cnf &
# ps -ef| grep mysql
root 17577 3102 0 03:12 pts/1 00:00:00 /bin/sh ./mysqld_safe --defaults-file=/etc/my.cnf
mysql 18618 17577 0 03:12 pts/1 00:00:00 /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql/mysql_3376/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/mysql_3376/data/error.log --pid-file=/data/mysql/mysql_3376/data/mysql.pid --socket=/tmp/mysql3376.sock --port=3376
root 18667 3102 0 03:12 pts/1 00:00:00 grep mysql
mysql.server调用mysqld_safe调用mysqld