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
Section titled “Important”You must have root access to the server to follow these procedures.
Problem
Section titled “Problem”When attempting to start MySQL, the server may:
- Run out of memory
- Fail to start completely
Resolution
Section titled “Resolution”The issue can usually be resolved by reducing MySQL’s memory usage. Modify the my.cnf configuration file and restart the server.
- 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=1Mset-variable = thread_stack=64Kset-variable = table_cache=4set-variable = sort_buffer=64Kset-variable = net_buffer_length=2Kset-variable = key_buffer_size=2095104skip-innodbskip-networkingskip-bdbskip-ndbcluster- Save the changes to
my.cnf. - Restart the MySQL server:
-
AlmaLinux / Fedora
Section titled “AlmaLinux / Fedora”
service mysqld restart-
Debian / Ubuntu
Section titled “Debian / Ubuntu”
service mysql restartAfter restarting, MySQL should run with reduced memory usage, resolving startup or memory issues.