Question

How to fix Error Prepare: Waiting for table metadata lock

Posted October 21, 2021 196 views
DigitalOcean Managed MySQL Database

I have a problem with the MySQL managed database, I am getting the following error:
Prepare: Waiting for table metadata lock

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hello,

The waiting for table metadata lock means, that there’s another transaction operating on that table for a long time. 

Using an Account that has the PROCESS privilege you can use the query below to see all the threads running:

You can cancel queries from the MySQL if needed:

SHOW PROCESSLIST;
or 


SHOW FULL PROCESSLIST;

To cancel one of these threads run:
KILL <thread_id>;
https://dev.mysql.com/doc/refman/8.0/en/show-processlist.html

Hope that this helps.
Regards,
Priyanka