Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>That <code>ibdata1</code> isn't shrinking is a particularly annoying feature of MySQL. The <code>ibdata1</code> file can't actually be shrunk unless you delete all databases, remove the files and reload a dump.</p> <p>But you can configure MySQL so that each table, including its indexes, is stored as a separate file. In that way <code>ibdata1</code> will not grow as large. According to <a href="https://stackoverflow.com/questions/3456159/how-to-shrink-purge-ibdata1-file-in-mysql#comment25251583_3456885">Bill Karwin's comment</a> this is enabled by default as of version 5.6.6 of MySQL.</p> <p>It was a while ago I did this. However, to setup your server to use separate files for each table you need to change <code>my.cnf</code> in order to enable this:</p> <pre><code>[mysqld] innodb_file_per_table=1 </code></pre> <p><a href="http://dev.mysql.com/doc/refman/5.5/en/innodb-multiple-tablespaces.html" rel="noreferrer">http://dev.mysql.com/doc/refman/5.5/en/innodb-multiple-tablespaces.html</a></p> <p>As you want to reclaim the space from <code>ibdata1</code> you actually have to delete the file:</p> <ol> <li>Do a <code>mysqldump</code> of all databases, procedures, triggers etc <strong>except the <code>mysql</code> and <code>performance_schema</code> databases</strong></li> <li>Drop all databases <strong>except the above 2 databases</strong></li> <li>Stop mysql</li> <li>Delete <code>ibdata1</code> and <code>ib_log</code> files</li> <li>Start mysql</li> <li>Restore from dump</li> </ol> <p>When you start MySQL in step 5 the <code>ibdata1</code> and <code>ib_log</code> files will be recreated. </p> <p>Now you're fit to go. When you create a new database for analysis, the tables will be located in separate <code>ibd*</code> files, not in <code>ibdata1</code>. As you usually drop the database soon after, the <code>ibd*</code> files will be deleted. </p> <p><a href="http://dev.mysql.com/doc/refman/5.1/en/drop-database.html" rel="noreferrer">http://dev.mysql.com/doc/refman/5.1/en/drop-database.html</a></p> <p>You have probably seen this:<br> <a href="http://bugs.mysql.com/bug.php?id=1341" rel="noreferrer">http://bugs.mysql.com/bug.php?id=1341</a></p> <p>By using the command <code>ALTER TABLE &lt;tablename&gt; ENGINE=innodb</code> or <code>OPTIMIZE TABLE &lt;tablename&gt;</code> one can extract data and index pages from ibdata1 to separate files. However, ibdata1 will not shrink unless you do the steps above.</p> <p>Regarding the <code>information_schema</code>, that is not necessary nor possible to drop. It is in fact just a bunch of read-only views, not tables. And there are no files associated with the them, not even a database directory. The <code>informations_schema</code> is using the memory db-engine and is dropped and regenerated upon stop/restart of mysqld. See <a href="https://dev.mysql.com/doc/refman/5.7/en/information-schema.html" rel="noreferrer">https://dev.mysql.com/doc/refman/5.7/en/information-schema.html</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload