MySQL on Ubuntu consuming almost all RAM -


i've been having issue mysql crashing randomly, apparently result of not having enough available memory (as discussed here: https://www.digitalocean.com/community/questions/mysql-on-ubuntu-keeps-crashing).

i increased server 4gb 8gb of ram (and have added 512mb swap), seems have helped crashing, when @ server, mysql still consuming absurd amount of memory. normal? how can prevent happening?

here screenshot htop: https://nick.do/images/htop.png

why there many instances of mysql taking 246m each?

here's my.conf file looks like:

# # mysql database server configuration file. # # can copy 1 of: # - "/etc/mysql/my.cnf" set global options, # - "~/.my.cnf" set user-specific options. #  # 1 can use long options program supports. # run program --help list of available options , # --print-defaults see understand , use. # # explanations see # http://dev.mysql.com/doc/mysql/en/server-system-variables.html  # passed mysql clients # has been reported passwords should enclosed ticks/quotes # escpecially if contain "#" chars... # remember edit /etc/mysql/debian.cnf when changing socket location. [client] port            = 3306 socket          = /var/run/mysqld/mysqld.sock  # here entries specific programs # following values assume have @ least 32m ram  # formally known [safe_mysqld]. both versions parsed. [mysqld_safe] socket          = /var/run/mysqld/mysqld.sock nice            = 0  [mysqld] # # * basic settings # user            = mysql pid-file        = /var/run/mysqld/mysqld.pid socket          = /var/run/mysqld/mysqld.sock port            = 3306 basedir         = /usr datadir         = /var/lib/mysql tmpdir          = /tmp lc-messages-dir = /usr/share/mysql skip-external-locking # # instead of skip-networking default listen on # localhost more compatible , not less secure. bind-address            = * # # * fine tuning # key_buffer              = 16m max_allowed_packet      = 16m thread_stack            = 192k thread_cache_size       = 8 # replaces startup script , checks myisam tables if needed # first time touched myisam-recover         = backup #max_connections        = 100 #table_cache            = 64 #thread_concurrency     = 10 # # * query cache configuration # query_cache_limit       = 1m query_cache_size        = 16m # # * logging , replication # # both location gets rotated cronjob. # aware log type performance killer. # of 5.1 can enable log @ runtime! #general_log_file        = /var/log/mysql/mysql.log #general_log             = 1 # # error log - should few entries. # log_error = /var/log/mysql/error.log # # here can see queries long duration #log_slow_queries       = /var/log/mysql/mysql-slow.log #long_query_time = 2 #log-queries-not-using-indexes # # following can used easy replay backup logs or replication. # note: if setting replication slave, see readme.debian #       other settings may need change. #server-id              = 1 #log_bin                        = /var/log/mysql/mysql-bin.log expire_logs_days        = 10 max_binlog_size         = 100m #binlog_do_db           = include_database_name #binlog_ignore_db       = include_database_name # # * innodb # # innodb enabled default 10mb datafile in /var/lib/mysql/. # read manual more innodb related options. there many! # # * security features # # read manual, too, if want chroot! # chroot = /var/lib/mysql/ # # generating ssl certificates recommend openssl gui "tinyca". # # ssl-ca=/etc/mysql/cacert.pem # ssl-cert=/etc/mysql/server-cert.pem # ssl-key=/etc/mysql/server-key.pem secure-file-priv = /var/tmp    [mysqldump] quick quote-names max_allowed_packet      = 16m  [mysql] #no-auto-rehash # faster start of mysql no tab completition  [isamchk] key_buffer              = 16m  # # * important: additional settings can override file! #   files must end '.cnf', otherwise they'll ignored. # !includedir /etc/mysql/conf.d/