How do I fix the "Out of sort memory" error?

Validated on 20 Nov 2024 • Last edited on 18 Mar 2026

ERROR 1038 (HY001): Out of sort memory, consider increasing server sort buffer size

Sort Buffer Size (sort_buffer_size) is a MySQL server system variable that can affect your query performance. It is defined on a per-session level, impacting your cluster’s memory consumption.

Warning
Changing sort_buffer_size can reduce query performance, increase overall memory consumption, and even crash your cluster. This process is highly specific to your workload and we do not recommend changing the default value. Please read its potential use cases and disclaimers before changing it.

To fix this error, increase sort_buffer_size to a value higher than its default of 256 KB. Having sort_buffer_size over 5 MB may significantly slow down memory allocation. To learn how to safely adjust sort_buffer_size, see our guide.

How do I fix the mysqldump "Couldn't execute FLUSH TABLES Access denied" error?

Update backup user permissions, remove the –single-transaction flag, or downgrade mysqldump.

Why does MySQL shut down when importing data with the source command?

Use MySQL’s import command instead of source for handling large data imports.

How do I fix the "1227" error?

Remove or replace the DEFINER in the dump file.

We can't find any results for your search.

Try using different keywords or simplifying your search terms.