title: Mysql using memory limit
body: <p>I have database (30mb only) and this database using 4gb ram! Max 10 people online in my site. I think that is bad cnf.my.</p>
  
  <pre>mysql> show variables like '%size%';
  
  
  +---------------------------------+----------------------+
  | Variable_name                   | Value                |
  +---------------------------------+----------------------+
  | binlog_cache_size               | 32768                |
  | bulk_insert_buffer_size         | 8388608              |
  | delayed_queue_size              | 1000                 |
  | innodb_additional_mem_pool_size | 1048576              |
  | innodb_buffer_pool_size         | 8388608              |
  | innodb_log_buffer_size          | 1048576              |
  | innodb_log_file_size            | 5242880              |
  | join_buffer_size                | 4194304              |
  | key_buffer_size                 | 268435456            |
  | key_cache_block_size            | 1024                 |
  | large_page_size                 | 0                    |
  | max_binlog_cache_size           | 18446744073709547520 |
  | max_binlog_size                 | 1073741824           |
  | max_heap_table_size             | 268435456            |
  | max_join_size                   | 18446744073709551615 |
  | max_long_data_size              | 1048576              |
  | max_relay_log_size              | 0                    |
  | myisam_data_pointer_size        | 6                    |
  | myisam_max_sort_file_size       | 9223372036853727232  |
  | myisam_mmap_size                | 18446744073709551615 |
  | myisam_sort_buffer_size         | 8388608              |
  | preload_buffer_size             | 32768                |
  | profiling_history_size          | 15                   |
  | query_alloc_block_size          | 8192                 |
  | query_cache_size                | 268435456            |
  | query_prealloc_size             | 8192                 |
  | range_alloc_block_size          | 4096                 |
  | read_buffer_size                | 131072               |
  | read_rnd_buffer_size            | 262144               |
  | sort_buffer_size                | 20971520             |
  | sql_max_join_size               | 18446744073709551615 |
  | thread_cache_size               | 4                    |
  | tmp_table_size                  | 41943040             |
  | transaction_alloc_block_size    | 8192                 |
  | transaction_prealloc_size       | 4096                 |
  +---------------------------------+----------------------+
  35 rows in set (0.00 sec)</pre>
  
  <p>And my.cnf:</p>
  
  <pre><code> [mysqld]
  
      local-infile=0
      datadir=/var/lib/mysql
      socket=/var/lib/mysql/mysql.sock
      long_query_time=1
      log-slow-queries=/var/log/mysql/log-slow-queries.log
      interactive_timeout=180
      wait_timeout=180
      max_connections=100
      innodb_buffer_pool_size=256M
      query_cache_size=256M
      key_buffer_size=256M
      sort_buffer_size=20M
      innodb_flush_log_at_trx_commit=0
      innodb_flush_method=O_DIRECT
      query_cache_type=1
      query_cache_limit=2M
      table_cache=1024
      join_buffer_size=4M
      thread_cache_size=4
      tmp_table_size=40M
      max_heap_table_size=256MB
  
      user=mysql
      symbolic-links=0
      #bind-address=127.0.0.1
  
      [mysqld_safe]
  
      log-error=/var/log/mysqld.log
      pid-file=/var/run/mysqld/mysqld.pid 
  </code></pre>
  
  <p>In my vps I have 5.7 gb ram</p>
  
  <p><strong>how to reduce memory usage?</strong></p>