The out of memory error means that mysql does not have enough memory to store the entire query result: You might have encountered below mentioned error message -
"
mysql: Out of memory at line 42, 'malloc.c'
mysql: needed 8136 byte (8k), memory in use: 12481367 bytes (12189k)
ERROR 2008: MySQL client ran out of memory"
In order to resolve this issue first check the query if it is correct. Is it reasonable that it should return so many rows? If not, correct the query and try again. Otherwise you need to invoke
quick option to resolve the issue. This option will not cache each query result, rather print each row as it is received. If the issue still persists then the only way to resolve the issue is by using
MySQL Repair software, which will repair the MySQL database and retain its cache value.
I hope this will help you out.
All the best!