Fix mysql high cpu usage on Ubuntu running WordPress
While doing maintenance to the Ubuntu server running mysql and apache2 using these commands:
SELECT tableschema AS “Database”, sum(datalength + indexlength)/1024/1024 AS “size in MB” FROM informationschema.TABLES GROUP BY table_schema;
optimize table wpcommentmeta, wpcomments, wplinks, wpodblogs, wpoptions, wppostmeta, wpposts, wptermrelationships, wptermtaxonomy, wptermmeta, wpterms, wpusermeta, wpusers, wpyoastseolinks, wpyoastseometa;
Then I went to the “Feedback” section of WordPress to delete old feedback around 24. Select them all and clicked “send” to trash.
Usually this process is quick. But it was taking a long time.
So I restarted the server, and now, mysql is taking all the cpu usage.
using the htop I see a bunch of /usr/sbin/mysql and one in particular is using most of CPU power.
Anyway to troubleshoot and fix this problem?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.×