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 said

    Thanks for sharing that.

    Very usefull script :)

  2. webdigity said

    No worries ;)

    I will try to post more usefull stuff later.

  3. stelmi said

    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 said

    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 said

    Are you kidding me with the code coloring?

  6. webdigity said

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

  7. Brian S said

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

  8. drmike said

    Thanks. :)

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

    Yes/No?

    Thanks,
    -drmike

  9. webdigity said

    Why to flush tables after the optimizing process?

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

  11. [...] 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 said

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

  13. machiner said

    Schweet script. Fast. Thank you for writing it.

    –machiner

  14. 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. [...] 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 said

    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> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>