title: Schrödingers MySQL table: exists, yet it does not
body: <p>I am having the weirdest error of all.</p>
  
  <p>Sometimes, when creating or altering tables, I get the 'table already exists' error. However, DROP TABLE returns '#1051 - unknown table'. So I got a table I cannot create, cannot drop.</p>
  
  <p>When I try to drop the database, mysqld crashes. Sometimes it helps to create another db with different name, sometimes it does not.</p>
  
  <p>I use a DB with ~50 tables, all InnoDB. This problem occurs with different tables.</p>
  
  <p>I experienced this on Windows, Fedora and Ubuntu, MySQL 5.1 and 5.5. Same behaviour, when using PDO, PHPMyAdmin or commandline. I use MySQL Workbench to manage my schema - I saw some related errors (endlines and stuff), however none of them were relevant for me.</p>
  
  <p>No, it is not a view, it is a table. All names are lowercase.</p>
  
  <p>I tried everything I could google - flushing tables, moving .frm files from db to db, reading mysql log, nothing helped but reinstalling the whole damn thing.</p>
  
  <p>'Show tables' reveals nothing, 'describe' table says 'table doesn't exist,' there is no .frm file, yet 'create table' still ends with an error (and so does 'create table if not exists') and dropping database crashes mysql</p>
  
  <p>Related, yet unhelpful questions: </p>
  
  <ul>
  <li><p><a href="https://stackoverflow.com/questions/3302476/mysql-1050-error-table-already-exists-when-in-fact-it-does-not">Mysql 1050 Error &quot;Table already exists&quot; when in fact, it does not</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/4260546/mysql-table-does-not-exist-error-but-it-does-exist">MySQL Table does not exist error, but it does exist</a></p></li>
  </ul>
  
  <p>Edit:</p>
  
  <pre><code>mysql&gt; use askyou;
  Database changed
  
  mysql&gt; show tables;
  Empty set (0.00 sec)
  
  mysql&gt; create table users_has_friends (id int primary key);
  ERROR 1050 (42S01): Table '`askyou`.`users_has_friends`' already exists
  
  mysql&gt; drop table users_has_friends;
  ERROR 1051 (42S02): Unknown table 'users_has_friends'
  </code></pre>
  
  <p>And such, all the same: table doesn't exist, yet cannot be created;</p>
  
  <pre><code>mysql&gt; drop database askyou;
  ERROR 2013 (HY000): Lost connection to MySQL server during query
  </code></pre>
  
  <p>Names change, this is not the only table / database I've run into problems with</p>