连接
- 连接远程数据库:
mysql -u <username> -p -h <host-ip> -P <port> -D <database>
查询每次SQL语句的具体执行情况
- 查看当前session的profiling情况:
select @@profiling;
- 打开profiling:
set profiling = 1;
- 执行一些sql
- 查看所有已执行的profile:
show profiles;
- 看看刚才某条sql执行的具体时间拆分:
show profile for query [queryID];
- 看看刚才某条sql执行的具体时间拆分,并加上相应的cpu信息:
show profile cpu for query [queryID];
查看正在执行的SQL语句
show processlist;