om/数据库/mysql/线程占用.md

27 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

```
information_schema这张数据表保存了MySQL服务器所有数据库的信息。如数据库名数据库的表表栏的数据类型与访问权限等。再简单点这台MySQL服务器上到底有哪些数据库、各个数据库有哪些表每张表的字段类型是什么各个数据库要什么权限才能访问等等信息都保存在information_schema表里面。
```
1. `innodb_trx` 当前运行的所有事务
2. `innodb_locks` 当前出现的锁
3. `innodb_lock_waits` 锁等待的对应关系
```sql
-- 查看哪个事物占用锁
select * from information_schema.innodb_trx;
select trx_mysql_thread_id from information_schema.innodb_trx where trx_state ='LOCK WAIT ';
-- 查看所有进程
show full processlist;
```
连接超时
```shell
The last packet successfully received from the server was 235,944,824 milliseconds ago. The last packet sent successfully to the server was 235,944,824 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
```