How to handle lock timeout error in MySQL?
This is not a MySQL configuration problem, it is an application problem.

You apparently have one connection hanging onto something for more than 50 seconds (the default for lock_wait_timeout).  I consider even 5 seconds to be much too long for an interactive system to hang onto something.

Find the other piece of code and rethink its logic.