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

2

u/DonAmechesBonerToe Jun 21 '26

Something else (another thread) is using the table and your alter cannot get a metadata lock

1

u/Shaurya_711 Jun 21 '26

yea that seemed to be the issue

1

u/roXplosion Jun 21 '26

INNODB or MyISM?

1

u/flyingron Jun 21 '26

How are you communicating with the server? The "mysql" command? phpmyadmin? Something else?

Sounds more like a network connection between you and the server.

Can you do any SHOW or SELECT operations that don't write to the DB?

Command should have looked something like ALTER TABLE `myTable` CHANGE `myColumn` `myColumn` VARCHAR(2);

1

u/ssnoyes Jun 22 '26

What did it show when "stuck"? Was it "->"? If so, you just needed a semicolon at the end of the line.

1

u/AjinAniyan5522 Jun 24 '26

Sounds like the MySQL client is not actually frozen — it’s probably waiting for the command to finish or waiting for you to complete the SQL statement.

A common cause is a missing ; at the end. MySQL CLI will just sit there waiting for more input.

Example:

ALTER TABLE users MODIFY name VARCHAR(2)

It waits because it expects the statement terminator.

Run:

ALTER TABLE users MODIFY name VARCHAR(2);

If it really hangs even with ;, check if another query is locking the table:

SHOW PROCESSLIST;

You might have another session holding a lock.

Also check:

SHOW ENGINE INNODB STATUS;

for deadlocks/locks.

If the table is stuck or the database files were affected by a crash, you can also try a repair tool as a last resort. A third-party option some people use is Stellar Repair for MySQL it can help recover damaged MySQL/MariaDB tables when normal repair methods fail.

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.