mysql在关闭时的几个阶段

mysql关闭的大致过程
  1、The shutdown process is initiated
    初始化关机过程有许多种方法1、mysqladmin shutdown ; 2、kill pid_of_mysqld
  2、The server creates a shutdown thread if necessary
    要不要创建这个线程取决于关闭操作的发起方式
  3、The server stops accepting new connections.
    mysql不再接受新的连接
  4、The server terminates current activity
    mysql开始终止已有的连接,如果事务正在执行那么就回滚。
    如果要关闭的mysql是主库,它不会区分是来自slave的连接还是一般的客户端连接
    如果要关闭的mysql是从库,它会保证SQL-thread完成它当前正在做的这个事务;等SQL-thread完成后再关闭
  5、The server shuts down or closes storage engines
    在这个阶段mysql会刷新所有的表缓存并关闭打开的文件
  6、The server exits

原文地址:https://www.cnblogs.com/JiangLe/p/6098471.html