Using the mysql_upgrade Command

What is mysql_upgrade?

If your server runs MySQL databases, then the mysql_upgrade command is one you’ll want to familiarize yourself with. Available only in Unix, mysql_upgrade is a command that checks all tables in all databases for incompatibilities with your current version of the MySQL Server.

After checking your databases, if a table is found to have possible incompatibilities, it is investigated in detail. If any problems are found, the table is repaired automatically.

Once all tables have been checked and repaired, they are marked with the current MySQL version number. This ensures that the next time you run the mysql_upgrade command with the same version of the server, it can determine whether there is any need to check or repair these tables again.

Another feature of mysql_upgrade is that it saves the MySQL version number into a file named Contained within the data directory, this file is used to quickly review if all tables are current for this release, allowing future table-checking to be skipped.

Lastly, mysql_upgrade also upgrades the system tables. This allows users to take advantage of new privileges or capabilities that might have been added in new versions of MySQL.

For these reasons, mysql_upgrade should be executed each time you upgrade the MySQL Server to ensure that your tables remain up-to-date and compatible. 


How to Use mysq_upgrade

To use mysql_upgrade, you’ll first need to make sure that your server is up and running. Then, from within the terminal, enter the following command:

shell> mysql_upgrade

The way mysql_upgrade works, is by automatically executing the following commands:

mysqlcheck --check-upgrade --all-databases --auto-repair


Additional Links:

Looking for more information on MySQL? Search our Knowledge Base!  

In need of more great content? Interested in cPanel, Private Cloud, or Colocation? Check out our recent posts for more news, guides, and industry insights!

Share on Twitter
Share on Facebook