Knowledge Base

MySQL server runs out of memory or does not start

This article describes how to resolve a problem that may occur when you try to run MySQL server with a limited amount of memory.

You must have root access to the server to follow the procedures in this article.

Problem

When you try to run MySQL server, it either runs out of memory or does not start at all.

Resolution

You can resolve this problem by reducing the amount of memory that MySQL uses. To do this, modify the my.cnf configuration file and restart the MySQL server as follows:

  1. Use the nano or vi text editor to open the /etc/my.cnf file.
  2. Make the following changes to the my.cnf file. You may need to add some of these lines, or uncomment existing lines by removing the leading #.
    set-variable = max_allowed_packet=1M
    set-variable = thread_stack=64K
    set-variable = table_cache=4
    set-variable = sort_buffer=64K
    set-variable = net_buffer_length=2K
    set-variable = key_buffer_size=2095104
    skip-innodb
    skip-networking
    skip-bdb
    skip-ndbcluster
  3. Save the changes to the my.cnf file.

  4. Restart MySQL server. To do this, type the appropriate command for your Linux distribution:

    • For CentOS and Fedora, type:
      service mysqld restart
    • For Debian and Ubuntu, type:

      service mysql restart