2.11.1 Upgrading MySQL

2.11.1.1 Changes Affecting Upgrades to MySQL 5.6
2.11.1.2 Upgrading MySQL with the MySQL Yum Repository
2.11.1.3 Upgrading MySQL with the MySQL APT Repository

This section describes how to upgrade to a new MySQL version.

Note

In the following discussion, MySQL commands that must be run using a MySQL account with administrative privileges include -u root on the command line to specify the MySQL root user. Commands that require a password for root also include a -p option. Because -p is followed by no option value, such commands prompt for the password. Type the password when prompted and press Enter.

SQL statements can be executed using the mysql command-line client (connect as root to ensure that you have the necessary privileges).

Supported Upgrade Methods

Supported downgrade methods include:

For in-place and logical upgrade procedures, see Performing an In-Place Upgrade, and Performing a Logical Upgrade.

If you run MySQL Server on Windows, see Section 2.3.8, “Upgrading MySQL on Windows”.

If your current MySQL installation was installed on an Enterprise Linux platform or Fedora using the MySQL Yum Repository, see Section 2.11.1.2, “Upgrading MySQL with the MySQL Yum Repository”.

If your current MySQL installation was installed on Ubuntu using the MySQL APT repository, see Section 2.11.1.3, “Upgrading MySQL with the MySQL APT Repository”.

Supported Upgrade Paths

Unless otherwise documented, the following upgrade paths are supported:

The following conditions apply to all upgrade paths:

Before You Begin

Before upgrading, review the following information and perform the recommended steps:

Performing an In-Place Upgrade

This section describes how to perform an in-place upgrade. Review Before you Begin before proceeding.

Note

If you upgrade an installation originally produced by installing multiple RPM packages, upgrade all the packages, not just some. For example, if you previously installed the server and client RPMs, do not upgrade just the server RPM.

To perform an in-place upgrade:

  1. Review the changes described in Section 2.11.1.1, “Changes Affecting Upgrades to MySQL 5.6” for steps to be performed before upgrading.

  2. If you use InnoDB, configure MySQL to perform a slow shutdown by setting innodb_fast_shutdown to 0. For example:

    mysql -u root -p --execute="SET GLOBAL innodb_fast_shutdown=0"
    

    With a slow shutdown, InnoDB performs a full purge and change buffer merge before shutting down, which ensures that data files are fully prepared in case of file format differences between releases.

  3. Shut down the old MySQL server. For example:

    mysqladmin -u root -p shutdown
    
  4. Upgrade the MySQL binaries or packages in place (replace the old binaries or packages with the new ones).

  5. Start the MySQL 5.6 server, using the existing data directory. For example:

    mysqld_safe --user=mysql --datadir=/path/to/existing-datadir
    
  6. Run mysql_upgrade. For example:

    mysql_upgrade -u root -p
    

    mysql_upgrade examines all tables in all databases for incompatibilities with the current version of MySQL. mysql_upgrade also upgrades the mysql system database so that you can take advantage of new privileges or capabilities.

    Note

    mysql_upgrade should not be used when the server is running with --gtid-mode=ON. See GTID mode and mysql_upgrade for more information.

    mysql_upgrade does not upgrade the contents of the help tables. For upgrade instructions, see Section 5.1.10, “Server-Side Help”.

  7. Shut down and restart the MySQL server to ensure that any changes made to the system tables take effect. For example:

    mysqladmin -u root -p shutdown
    mysqld_safe --user=mysql --datadir=/path/to/existing-datadir
    

Performing a Logical Upgrade

This section describes how to perform a logical upgrade. Review Before you Begin before proceeding.

To perform a logical upgrade:

  1. Review the changes described in Section 2.11.1.1, “Changes Affecting Upgrades to MySQL 5.6” for steps to be performed before upgrading.

  2. Export your existing data from the previous MySQL version:

    mysqldump -u root -p
      --add-drop-table --routines --events
      --all-databases --force > data-for-upgrade.sql
    
    Note

    Use the --routines and --events options with mysqldump (as shown above) if your databases include stored programs. The --all-databases option includes all databases in the dump, including the mysql database that holds the system tables.

  3. Shut down the old MySQL server. For example:

    mysqladmin -u root -p shutdown
    
  4. Install MySQL 5.6. For installation instructions, see Chapter 2, Installing and Upgrading MySQL.

  5. Initialize a new data directory, as described at Section 2.10.1, “Initializing the Data Directory”. For example:

    scripts/mysql_install_db --user=mysql --datadir=/path/to/5.6-datadir
    
  6. Start the MySQL 5.6 server, using the new data directory. For example:

    mysqld_safe --user=mysql --datadir=/path/to/5.6-datadir
    
  7. Load the previously created dump file into the new MySQL server. For example:

    mysql -u root -p --force < data-for-upgrade.sql
    
  8. Run mysql_upgrade. For example:

    mysql_upgrade -u root -p
    

    mysql_upgrade examines all tables in all databases for incompatibilities with the current version of MySQL. mysql_upgrade also upgrades the mysql system database so that you can take advantage of new privileges or capabilities.

    Note

    mysql_upgrade should not be used when the server is running with --gtid-mode=ON. See GTID mode and mysql_upgrade for more information.

    mysql_upgrade does not upgrade the contents of the help tables. For upgrade instructions, see Section 5.1.10, “Server-Side Help”.

  9. Shut down and restart the MySQL server to ensure that any changes made to the system tables take effect. For example:

    mysqladmin -u root -p shutdown
    mysqld_safe --user=mysql --datadir=/path/to/5.6-datadir
    

Upgrade Troubleshooting