linux 下远程连接mysq
命令:
mysql -h "1.0.0.1" -u username -p
<div class="p18">1?获 取锁等待情况
<div class="p0">可以通过检查 table_locks_waited和table_locks_immediate状态变量来分析系统上的表锁定争夺:
<div class="p0">mysql> show status like 'Table%';
<div class="p0">+----------------------------+----------+
<div class="p0">| Variable_name?| Value?|
<div class="p0">+----------------------------+----------+
<div class="p0">| Table_locks_immediate?| 105?|
<div class="p0">| Table_locks_waited?| 3?|
<div class="p0">+----------------------------+----------+
<div class="p0">2 rows in set (0.00 sec)
<div class="p0">?
<div class="p0">可以通过检查 Innodb_row_lock状态变量来分析系统上的行锁的争夺情况:
<div class="p0">mysql> show status like 'innodb_row_lock%';
<div class="p0">+----------------------------------------+----------+
<div class="p0">| Variable_name?| Value?|
<div class="p0">+----------------------------------------+----------+
<div class="p0">| Innodb_row_lock_current_waits?| 0?|
<div class="p0">| Innodb_row_lock_time?| 2001?|
<div class="p0">| Innodb_row_lock_time_avg?| 667?|
<div class="p0">| Innodb_row_lock_time_max?| 845?|
<div class="p0">| Innodb_row_lock_waits?| 3?|
<div class="p0">+----------------------------------------+----------+
<div class="p0">5 rows in set (0.00 sec)
<div class="p0">?
<div class="p0">另外,针对Innodb类型的表,如果 需要察看当前的锁等待情况,可以设置InnoDB Monitors,然后通过Show innodb status察看,设置的方式是:
<div class="p0">CREATE TABLE innodb_monitor(a INT) ENGINE=INNODB;
<div class="p0">监视器可以通过发出下列语句来被停止:
<div class="p0">DROP TABLE innodb_monitor;
<div class="p0">设置监视器后,在show innodb status的显示内容中,会有详细的当前锁等待的信息,包括表名、锁类型、锁定记录的情况等等,便于进行进一步的分析和问题的确定。打开监视器以后,默 认情况下每15秒会向日志中记录监控的内容,如果长时间打开会导致.err文件变得非常的巨大,所以我们在确认问题原因之后,要记得删除监控表以关闭监视 器。或者通过使用--console选项来启动服务器以关闭写日志文件。如果是root帐号,你能看到所有用户的当前连接。如果是其它普通帐号,只能看到自己占用的连接。?<span style="color: #ff0000;">show processlist;只 列出前100条,如果想全列出请使用<span style="color: #ff0000;">show full processlist;?mysql> show processlist;(非常管用哦)
?来自:http://5iwww.blog.51cto.com/856039/340985 (编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|