2 thoughts on “littlebat关于mysql使用中的一些疑问汇总”

  1. JAVA学习日记是租用的jsp虚拟空间。这两天经常出现数据库连接超过空间商的用户最大连接数,不知道问题出在什么地方。

    我知道用 show variables;可以查看系统设置的允许最大连接数 max_connections 和允许每个用户的最大连接数max_user_connections ,用show status; 可以查看系统当前的总连接用户数Threads_connected (是连接的用户,不是连接,一个用户同时可有多个并发连接吧?不是很懂。)

    但是就是不知道怎么查看自己的当前活动连接数。

  2. 好像用show processlist; 命令可以查看当前用户正在处理的线程,这个线程是不是就是当前用户对数据库的并发连接呢?是不是虚拟主机限定的“max_user_connections”呢?

    下面这段是摘自mysql的官方文档:http://dev.mysql.com/doc/refman/5.0/en/show-processlist.html


    13.5.4.20. SHOW PROCESSLIST Syntax

    SHOW [FULL] PROCESSLIST

    SHOW PROCESSLIST shows you which threads are running. You can also get this information using the mysqladmin processlist command. If you have the PROCESS privilege, you can see all threads. Otherwise, you can see only your own threads (that is, threads associated with the MySQL account that you are using). See Section 13.5.5.3, “KILL Syntax”. If you do not use the FULL keyword, only the first 100 characters of each statement are shown in the Info field.

    This statement is very useful if you get the “too many connections” error message and want to find out what is going on. MySQL reserves one extra connection to be used by accounts that have the SUPER privilege, to ensure that administrators should always be able to connect and check the system (assuming that you are not giving this privilege to all your users).

    The output of SHOW PROCESSLIST may look like this:

    mysql> SHOW FULL PROCESSLIST\G

Comments are closed.