Webdigity - Thoughts on SEO and Web development

Automatically optimize all tables in a MySQL database

Posted by webdigity on June 9, 2006

Use this script preferably with a cronjob to automatically optimize all the tables in your mysql databases. Under root privilleges the script will search for all the databases in your server and will optimize them all. Hope you will like it as it took me more than 3 hours to write it :)

 

Optimize all databases/tables in MySQL
For more tutorials you can refer here

16 Responses to “Automatically optimize all tables in a MySQL database”

  1. Niche Says:

    Thanks for sharing that.

    Very usefull script :)

  2. webdigity Says:

    No worries ;)

    I will try to post more usefull stuff later.

  3. stelmi Says:

    Why are you don’t use mysqlcheck application? I think it will be easier to run this program from crontab with appropraite option. MOre detail are here:

    http://dev.mysql.com/doc/refman/5.0/en/mysqlcheck.html

  4. webdigity Says:

    mysqlcheck is a little slow, but the most important is that it can break tables that have unicode charsets.

    Anyway this script optimizes only tables that want optimization, while the mysqlcheck optimizes everything.

  5. sup Says:

    Are you kidding me with the code coloring?

  6. webdigity Says:

    If you can’t read it, just copy/paste it somewhere my friend :)

  7. Brian S Says:

    Works beautifully. Implemented on all of my servers. Thanks. :)

  8. drmike Says:

    Thanks. :)

    I’ve found mention of how one should run a FLUSH TABLES after optimizing one’s db.

    Yes/No?

    Thanks,
    -drmike

  9. webdigity Says:

    Why to flush tables after the optimizing process?

  10. Dr. Mikes Blog » Optimize MySQL Says:

    [...] code for the most part comes from here with some modifications made by myself to allow for the WPMu system. Instructions are included [...]

  11. Optimize MySQL « Dr. Mike’s Blog Says:

    [...] code for the most part comes from here with some modifications made by myself to allow for the WPMu system. Instructions are included [...]

  12. GreyDuck Says:

    This is exactly the piece of kit I was looking for. Thank you!

  13. machiner Says:

    Schweet script. Fast. Thank you for writing it.

    –machiner

  14. Web 2.0 Announcer Says:

    Automatically optimize all tables in a MySQL database

    [...]Use this script preferably with a cronjob to automatically optimize all the tables in your mysql databases. Under root privilleges the script will search for all the databases in your server and will optimize them all.[...]

  15. tending the garden » links for 2007-06-14 Says:

    [...] Automatically optimize all tables in a MySQL database « Webdigity - Thoughts on SEO and Web develop… optimize - a script for running it automatically (tags: howto mysql optimization php script wordpress) [...]

  16. Tracy Says:

    I have implemented this script on one of my blogs, thanks very much

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>