1、查询数据库连接数
mysql> show status like 'Threads%';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| Threads_cached | 1 |
| Threads_connected | 100 | //是打开的连接数
| Threads_created | 171 |
| Threads_running | 1 | //激活的连接数,这个数值一般远低于connected数值
+-------------------+-------+
4 rows in set (0.00 sec)
2、查询数据库连接
如果是root帐号,你能看到所有用户的当前连接。如果是其它普通帐号,只能看到自己占用的连接。
show processlist;只列出前100条,如果想全列出请使用show full processlist;
mysql> show processlist;
3、查询数据库最大连接数
mysql> show variables like '%max_connections%';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 100 |
+-----------------+-------+
1 row in set (0.00 sec)
可以在/etc/my.cnf里面设置数据库的最大连接数
[mysqld]
max_connections = 1000