How to Optimize MySQL

Today I found my websites were very slow. Log into linode system and I found MySQL is over 500% CPU usage.

Just google it. and found a script.


  1. wget https://raw.github.com/major/MySQLTuner-perl/master/mysqltuner.pl

  2. use winscp to change the pl file to 777

  3. use putty to telnet the server.

  4. Just run the pl. ./mysqltuner.pl

  5. The pl will display some setting suggestion.  change ./etc/mysql/my.cnf

  6. Use the following command to optimize database tables
    mysqlcheck --optimize -A -u username -ppassword

  7. service mysql restart

  8. That's all.


 

Comments

Jesse Lau · @jesselaunz

Let's connect

Long-form on the blog, videos on YouTube, daily notes on 𝕏 — one person, one thread.