Jump to content

Sandeep B.

Recommended Posts

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

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...