查詢是否鎖表 show OPEN TABLES where In_use > 0; 查詢進程 show processlist 查詢到相對應的進程===然后 kill id

innodb_trx表:
trx_id:事務ID。
trx_state:事務狀態,有以下幾種狀態:RUNNING、LOCK WAIT、ROLLING BACK 和 COMMITTING。
trx_started:事務開始時間。
trx_requested_lock_id:事務當前正在等待鎖的標識,可以和 INNODB_LOCKS 表 JOIN 以得到更多詳細信息。
trx_wait_started:事務開始等待的時間。
trx_weight:事務的權重。
trx_mysql_thread_id:事務線程 ID,可以和 PROCESSLIST 表 JOIN。
trx_query:事務正在執行的 SQL 語句。
trx_operation_state:事務當前操作狀態。
trx_tables_in_use:當前事務執行的 SQL 中使用的表的個數。
trx_tables_locked:當前執行 SQL 的行鎖數量。
trx_lock_structs:事務保留的鎖數量。
trx_lock_memory_bytes:事務鎖住的內存大小,單位為 BYTES。
trx_rows_locked:事務鎖住的記錄數。包含標記為 DELETED,並且已經保存到磁盤但對事務不可見的行。
trx_rows_modified:事務更改的行數。
trx_concurrency_tickets:事務並發票數。
trx_isolation_level:當前事務的隔離級別。
trx_unique_checks:是否打開唯一性檢查的標識。
trx_foreign_key_checks:是否打開外鍵檢查的標識。
trx_last_foreign_key_error:最后一次的外鍵錯誤信息。
trx_adaptive_hash_latched:自適應散列索引是否被當前事務鎖住的標識。
trx_adaptive_hash_timeout:是否立刻放棄為自適應散列索引搜索 LATCH 的標識。

innodb_locks表:
lock_id:鎖 ID。
lock_trx_id:擁有鎖的事務 ID。可以和 INNODB_TRX 表 JOIN 得到事務的詳細信息。
lock_mode:鎖的模式。有如下鎖類型:行級鎖包括:S、X、IS、IX,分別代表:共享鎖、排它鎖、意向共享鎖、意向排它鎖。表級鎖包括:S_GAP、X_GAP、IS_GAP、IX_GAP 和 AUTO_INC,分別代表共享間隙鎖、排它間隙鎖、意向共享間隙鎖、意向排它間隙鎖和自動遞增鎖。
lock_type:鎖的類型。RECORD 代表行級鎖,TABLE 代表表級鎖。
lock_table:被鎖定的或者包含鎖定記錄的表的名稱。
lock_index:當 LOCK_TYPE=’RECORD’ 時,表示索引的名稱;否則為 NULL。
lock_space:當 LOCK_TYPE=’RECORD’ 時,表示鎖定行的表空間 ID;否則為 NULL。
lock_page:當 LOCK_TYPE=’RECORD’ 時,表示鎖定行的頁號;否則為 NULL。
lock_rec:當 LOCK_TYPE=’RECORD’ 時,表示一堆頁面中鎖定行的數量,亦即被鎖定的記錄號;否則為 NULL。
lock_data:當 LOCK_TYPE=’RECORD’ 時,表示鎖定行的主鍵;否則為NULL。

innodb_lock_waits表:
requesting_trx_id:請求事務的 ID。
requested_lock_id:事務所等待的鎖定的 ID。可以和 INNODB_LOCKS 表 JOIN。
blocking_trx_id:阻塞事務的 ID。
blocking_lock_id:某一事務的鎖的 ID,該事務阻塞了另一事務的運行。可以和 INNODB_LOCKS 表 JOIN。
innodb_trx表查詢結果舉例: mysql(mdba@localhost:(none) 03:48:05)>select * from information_schema.innodb_trx \G *************************** 1. row *************************** trx_id: 3404472915 trx_state: RUNNING trx_started: 2017-07-20 15:48:14 trx_requested_lock_id: NULL trx_wait_started: NULL trx_weight: 3 trx_mysql_thread_id: 27044647 trx_query: commit trx_operation_state: committing trx_tables_in_use: 0 trx_tables_locked: 1 trx_lock_structs: 2 trx_lock_memory_bytes: 1136 trx_rows_locked: 1 trx_rows_modified: 1 trx_concurrency_tickets: 0 trx_isolation_level: REPEATABLE READ trx_unique_checks: 1 trx_foreign_key_checks: 1 trx_last_foreign_key_error: NULL trx_adaptive_hash_latched: 0 trx_adaptive_hash_timeout: 0 trx_is_read_only: 0 trx_autocommit_non_locking: 0 *************************** 2. row *************************** trx_id: 3404264783 trx_state: RUNNING trx_started: 2017-07-20 15:42:06 trx_requested_lock_id: NULL trx_wait_started: NULL trx_weight: 2 trx_mysql_thread_id: 22514654 trx_query: update qymc set status1='2' where id=962304 trx_operation_state: NULL trx_tables_in_use: 0 trx_tables_locked: 1 trx_lock_structs: 1 trx_lock_memory_bytes: 1136 trx_rows_locked: 0 trx_rows_modified: 1 trx_concurrency_tickets: 0 trx_isolation_level: REPEATABLE READ trx_unique_checks: 1 trx_foreign_key_checks: 1 trx_last_foreign_key_error: NULL trx_adaptive_hash_latched: 0 trx_adaptive_hash_timeout: 0 trx_is_read_only: 0 trx_autocommit_non_locking: 0