<p>I am trying to delete several rows from a MySQL 5.0.45 database:</p>

<pre><code>delete from bundle_inclusions;
</code></pre>

<p>The client works for a while and then returns the error:</p>

<pre><code>Lock wait timeout exceeded; try restarting transaction
</code></pre>

<p>It's possible there is some uncommitted transaction out there that has a lock on this table, but I need this process to trump any such locks.  How do I break the lock in MySQL?</p>

[{'answer_id': 64695, 'author': 'Erik', 'author_id': 6733, 'author_profile': 'https://Stackoverflow.com/users/6733', 'pm_score': 2, 'selected': False, 'text': '<p>Guessing:  truncate table bundle_inclusions</p>\n'}, {'answer_id': 64771, 'author': 'Matt Solnit', 'author_id': 6198, 'author_profile': 'https://Stackoverflow.com/users/6198', 'pm_score': 6, 'selected': True, 'text': "<p>I agree with Erik; TRUNCATE TABLE is the way to go.  However, if you can't use that for some reason (for example, if you don't <em>really</em> want to delete every row in the table), you can try the following options:</p>\n\n<ul>\n<li>Delete the rows in smaller batches (e.g. DELETE FROM bundle_inclusions WHERE id BETWEEN ? and ?)</li>\n<li>If it's a MyISAM table (actually, this may work with InnoDB too), try issuing a LOCK TABLE before the DELETE.  This should guarantee that you have exclusive access.</li>\n<li>If it's an InnoDB table, then <em>after</em> the timeout occurs, use SHOW INNODB STATUS.  This should give you some insight into why the lock acquisition failed.</li>\n<li>If you have the SUPER privilege you could try SHOW PROCESSLIST ALL to see what other connections (if any) are using the table, and then use KILL to get rid of the one(s) you're competing with.</li>\n</ul>\n\n<p>I'm sure there are many other possibilities; I hope one of these help.</p>\n"}, {'answer_id': 10704454, 'author': 'Lars Bohl', 'author_id': 438960, 'author_profile': 'https://Stackoverflow.com/users/438960', 'pm_score': 3, 'selected': False, 'text': '<p>Linux: In mysql configuration (/etc/my.cnf or /etc/mysql/my.cnf), insert / edit this line</p>\n\n<pre><code>innodb_lock_wait_timeout = 50\n</code></pre>\n\n<p>Increase the value sufficiently (it is in seconds), restart database, perform changes. Then revert the change and restart again.</p>\n'}, {'answer_id': 15539899, 'author': 'Eric Cope', 'author_id': 256484, 'author_profile': 'https://Stackoverflow.com/users/256484', 'pm_score': 2, 'selected': False, 'text': "<p>I had the same issue, a rogue transaction without a end. I restarted the mysqld process. You don't need to truncate a table. You may lose data from that rogue transaction.</p>\n"}]
['https://Stackoverflow.com/questions/64653', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8344/']