MySQL check is a tool that gets installed along with installing MySQL database servers. It’s there to help analyse and fix common errors as well as optimize MySQL databases and tables.
The question is how does one use mysqlcheck command?
This brief post shows you how to use mysqlcheck to optimize and repair and fix common problems with MySQL databases.
Sometimes MySQL databases get corrupt or don’t function as efficiently as they should. These are just some of the problems you may find yourself trying to fix. In these situations, your first go-to tool should be mysqlcheck.
This tool comes with MySQL database client. It helps database administrators analyse, optimize and repair common issues found in managing MySQL or MariaDB databases and tables.
Follow the steps below to see what you can do with this command.
Step 1: Check all tables in a particular database
mysqlcheck -c database_name
If your database server has a password, use the command below.
mysqlcheck -c databse_name -u username -p
Step 2: Analyse all tables in a particular database
mysqlcheck -a database-name
If your database server has a password, run the commands below
mysqlcheck -a database_name -u username -p
Step 3: Optimize all databases
mysqlcheck -o --all-databases
Again, if you setup password on your database server, run the commands below.
mysqlcheck -o --all-databases -u username -p
Step 4: Repair a particular database
mysqlcheck -r database_name
With password on database server, run the commands below
mysqlcheck -r database_name -u username -p
Step 5: Optimize and Repair MySQL databases
mysqlcheck --auto-repair -o --all-databases
With username and password, run the commands below
mysqlcheck --auto-repair -o --all-databases -u username -p
A table to help you:
|-c, –check||Check table for errors.|
|-a, –analyze||Analyze given tables.|
|-o –optimize||Optimize the tables.|
|-r, –repair||Perform a repair that can fix almost anything except unique keys that are not unique.|
|–auto-repair||If a checked table is corrupted, automatically fix it. Repairing will be done after all tables have been checked.|
|-A, –all-databases||Check all the databases. This is the same as –databases with all databases selected.|
|-B, –databases||Process all tables in the named databases. With this option, all name arguments are regarded as database names, not as table names.|
|–tables||Overrides the –databases or -B option such that all name arguments following the option are regarded as table names.|
|-g, –check-upgrade||Check tables for version-dependent changes. May be used with –auto-repair to correct tables requiring version-dependent updates.|
- Installing MySQL Latest Versions on Ubuntu 17.04
- How to Install the Latest MySQL 5.7 on Ubuntu 17.04
- Install MySQL 8.0 on Ubuntu 16.04 / 17.10 / 18.04
- Resetting MySQL Root Password on Ubuntu 16.04 / 17.10 and 18.04 LTS
- MySQL Server 8.0.14 Released — Here’s How to Install / Upgrade on Ubuntu 16.04 / 18.04
- Today’s Lesson: How To Install MySQL Server on Ubuntu
- How do You Install MySQL on Ubuntu
- Managing MySQL Databases via phpMyAdmin on Ubuntu?
- Students question – How to Reset MySQL Root Password?