This usually happens when you’re doing massive queries on InnoDB tables:
ERROR 1206 (HY000): The total number of locks exceeds the lock table size
In /etc/my.cnf, do something like this:
innodb_buffer_pool_size=524288000
By default, MySQL sets innodb_buffer_pool_size to 8MB.
500 megabytes = 524 288 000 bytes