MySQL Error: Thread stack overrun

Recently, I’ve come across this error:

MySQL error 1436: Thread stack overrun:
164720 bytes used of a 196608 byte stack, and 32000 bytes needed.
Use ‘mysqld –thread_stack=#’ to specify a bigger stack.

I am using PHP 7.0 and MySQL 5.7 on a Ubuntu 16.04 VM. Basically, I was dynamically creating more than 5 long SQL select commands and executing them.

I’ve found some more information on MySQL’s website:
Connection threads

As a summary, they say:

When the thread stack is too small, this limits the complexity of the SQL statements which the server can handle, the recursion depth of stored procedures, and other memory-consuming actions.

So, I’ve edited the configuration file:


Changed the entry for thread_stack from 192k to 512k:

thread_stack = 512k

256k was not enough in my case.

Leave a Reply