MySQL Server Runs Out of Memory or Does Not Start
This guide explains how to fix issues when your MySQL server runs out of memory or fails to start.
Important
You must have root access to the server to follow these procedures.
Problem
When attempting to start MySQL, the server may:
-
Run out of memory
-
Fail to start completely
Resolution
The issue can usually be resolved by reducing MySQL’s memory usage. Modify the my.cnf configuration file and restart the server.
Steps
-
Open the MySQL configuration file with a text editor (
nanoorvi):
nano /etc/my.cnf
-
Add or modify the following lines (uncomment existing lines if necessary):
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
-
Save the changes to
my.cnf. -
Restart the MySQL server:
-
AlmaLinux / Fedora:
service mysqld restart
-
Debian / Ubuntu:
service mysql restart
After restarting, MySQL should run with reduced memory usage, resolving startup or memory issues.