一.开启慢查询日志 通过show global variables like '%slow%' #查看MySQL慢查询日志是否开启 [root@mysqlmaster01 ~]# mysql --login-path=mysql57Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 21Server version: 5.7.20-log MySQL Community Serve…
laravel文档好像没有写得很详细 https://docs.golaravel.com/docs/5.3/database/ Using Multiple Database Connections When using multiple connections, you may access each connection via the connection method on the DB facade. The name passed to the connection method…
工作中,会遇到需要查看mysql的top 20 慢sql,逐个进行优化,加上必要的索引这种需求,这时就需要开启数据库的慢查询日志的功能 1.查询当前慢查询日志的状态 # 默认为关闭状态 mysql ---------------------------- show variables like "%slow_query_log%"; ---------------------------- # 实例演示: mysql> show variables like "%slo…