aapanelCentosControl PanelCWPHestia CPLinuxMySQLUbuntuVesta CP

Optimize and Repair MySQL Database via CLI CWP/Centos/Ubuntu/EL7/EL8

Today we’ll learn how we can optimize and repair MySQL databases via command line interface, probably you’ve already optimized and repaired dbs via phpMyAdmin options and its easy to use, but what about you’ve too many databases and wanting to repair and optimize it at once?

No worry today I’ll show you easy way to do it via CLI with single command each for repairing and optimizing databases.

To Repair ALL Database you need to simply run this command :

mysqlcheck -r --all-databases

If you want to Repair single database then use this :

mysqlcheck -r user_db

*user_db is the db name, replace with your one.

To Optimize ALL Database you need to simply run this command :

mysqlcheck -o --all-databases

If you want to Optimize single database then use this :

mysqlcheck -o user_db

*user_db is the db name, replace with your one.

Extras :

If you need to specify username to do the repair and optimize task you can add this pipes :

mysqlcheck -r  -u root -p --all-databases
mysqlcheck -o  -u root -p --all-databases

of for single database :

mysqlcheck -r user_db -u root -p
mysqlcheck -o user_db -u root -p

*this will ask the password for mysql root user

Sandeep B.

I'm a system admin and php developer and currently working as System Admin In CWP Control panel, expertise in Linux and Windows administration RHEL certified admin.

Related Articles

One Comment

Leave a Reply

Your email address will not be published.

Back to top button