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.
Table of Contents


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


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
  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 AlmaLinux and Fedora, type:
      service mysqld restart
    • For Debian and Ubuntu, type:

      service mysql restart
Get MySQL Hosting

Article Details

Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.

We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.