How can I set the max number of MySQL processes or threads?

后端 未结 4 1986
失恋的感觉
失恋的感觉 2021-02-03 22:48

ps axuw| grep mysql indicates only MySQL process, but if I run htop I can see 10 rows each one of them with a separate PID. So I wonder if they are threads or proce

相关标签:
4条回答
  • 2021-02-03 23:23

    MySQL does use threads, ps can see them if you run ps -eLf.

    That said, I wouldn't worry about it - dormant threads use almost no resources whatsoever, and if you constrain the server too much it's bound to come back and bite you on the backside sometime later when you've forgotten that you did it.

    0 讨论(0)
  • 2021-02-03 23:24

    You can set the max number of threads in your my.ini like this:

    max_connections=2
    

    However you might also want to set this:

    thread_cache_size=1
    

    The thread cache controls how many it keeps open even when nothing is happening.

    0 讨论(0)
  • 2021-02-03 23:31

    There is few configuration settings in /etc/mysql/my.cnf that would impact memory usage. Following settings: key_buffer = 8M max_connections = 30 query_cache_size = 8M query_cache_limit = 512K thread_stack = 128K should drastically reduce the memory usage of mysql.

    read more here: http://opensourcehacker.com/2011/03/31/reducing-mysql-memory-usage-on-ubuntu-debian-linux/

    0 讨论(0)
  • 2021-02-03 23:40

    I was seeking for MySQL config stuff, then I saw this question.... Nothing to do with MySQL, am I right ?

    If the main objective is to see the result of a custom command, you can use "watch" with the following syntax (available on most linux systems) :

    watch "ps axuw| grep mysql"
    

    It will run the command each 2 seconds and display the output, it is a very very useful command.

    -> See the doc/man to see how it's powerful ;)

    0 讨论(0)
提交回复
热议问题