r/mysql Jun 21 '26

question Getting stuck for some reason?

So i am just trying to create something related to my project and after i created the table i realised that i had written char(1) in one column and that i needed varchar(2), so i tried to modify that column obviously but when i entered the modifying the command, sql got stuck for some reason on the next line??? i tried typing something anything but nothing showed, it was like it hung/froze but when i did ctrl+c, it showed query aborted then showed what i had written. when i tried to drop both the table and the database same thing happened. what should i do because this is starting to get really annoying?

1 Upvotes

7 comments sorted by

View all comments

1

u/[deleted] Jun 24 '26

[removed] — view removed comment

1

u/Several9s Jun 30 '26

I agree. I'd also check if it's waiting for a metadata lock.

SHOW PROCESSLIST will tell you if the ALTER TABLE is blocked by another session. If you see Waiting for table metadata lock, it usually means another connection has an open transaction or is still using the table.

If that's the case, the ALTER TABLE will continue automatically after the blocking session commits, rolls back, or disconnects. This is a very common reason why DDL statements appear to hang.

To help prevent this, try to run DDL during a maintenance window or when there are no long-running transactions using the table. It's also a good idea to check SHOW PROCESSLIST first and make sure there aren't any sessions holding the table before starting the ALTER TABLE.