MyBB Community Forums

Full Version: SQL ERROR
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello

i lost my data do to server hosting issue , and now i am trying to restore my database but i got this error :

Error: The system failed to execute the database script with the following errors: ERROR 1100 (HY000) at line 209: Table 'mybb_attachments' was not locked with LOCK TABLES

please help me to fix this issue

thanks in advance
Possibly, this is due to unbalanced LOCK TABLES and UNLOCK TABLES pairs, in particular, a missing UNLOCK TABLES command after a block of queries begun with a LOCK TABLES. You might want to check whether any block of SQL commands (especially immediately) prior to the line beginning with
LOCK TABLES `mybb_attachments`
begins with LOCK TABLES but omits a closing UNLOCK TABLES. If so, try inserting the missing UNLOCK TABLES command and see how you go.
(2021-09-10, 07:17 AM)Laird Wrote: [ -> ]Possibly, this is due to unbalanced LOCK TABLES and UNLOCK TABLES pairs, in particular, a missing UNLOCK TABLES command after a block of queries begun with a LOCK TABLES. You might want to check whether any block of SQL commands (especially immediately) prior to the line beginning with
LOCK TABLES `mybb_attachments`
begins with LOCK TABLES but omits a closing UNLOCK TABLES. If so, try inserting the missing UNLOCK TABLES command and see how you go.

Hello Sir
thank you so much for your reply ,
I have checked all the possibilities but no luck.
any suggestion ?
(2021-09-10, 07:33 PM)aseermrmr Wrote: [ -> ]any suggestion ?

Nope. I have found somebody else on StackOverflow having the same problem, unfortunately without a solution though:

https://stackoverflow.com/questions/6086...ugh-it-was
so my data is gone forever ? Sad
Hopefully not. Maybe you could share your backup file with somebody whom you trust not to breach your members' privacy, and see whether they can debug the problem for you. If you're willing to trust me, I'd be happy to take a look - just message me privately.
(2021-09-11, 12:44 PM)Laird Wrote: [ -> ]Hopefully not. Maybe you could share your backup file with somebody whom you trust not to breach your members' privacy, and see whether they can debug the problem for you. If you're willing to trust me, I'd be happy to take a look - just message me privately.

sure i can trust you
i will send link to you know if you can check

Really thank you so much for your help
my site is working fine now , thanks to you
No worries. Glad we solved the problem.

Just for the benefit of readers: the problem was, indeed, that there was an unbalanced LOCK TABLES and UNLOCK TABLES pair (a missing UNLOCK TABLES command just prior to the LOCK TABLES command for the mybb_attachments table).

Curiously, this did not cause a problem on my local machine on which MariaDB is installed. Presumably, that's due to MariaDB implicitly performing an UNLOCK TABLES just prior to respecting a LOCK TABLES query - at least for the particular version of MariaDB that's installed on my local machine. Apparently, though, this implicit command is not performed on all versions of MySQL/MariaDB, so be careful to balance your LOCK/UNLOCK commands just to be sure.
Well done @Laird, +1 Smile

Curious how that sql file was created - not that it matters now.  But might matter going forward.  For those reading - always a good idea to test your backups.

A backup that can't be restored is no backup at all. Toungue