Hello Ghazanfar,
Per this document, “if you need to work with triggers or stored functions, make sure your instance has the log_bin_trust_function_creators flag set to on.”. You may configure flags (set it to on) by following this guide.
For further help with your query code (or syntax), you may post your question at stackoverflow.com with the proper mysql flags where you have access to a large community of enthusiasts and experts to share ideas with and get support from. I found a similar question at this link. I hope this helps.