2.11 Downgrading MySQL

This section describes the steps to downgrade a MySQL installation.

Downgrading is a less common operation than upgrade. Downgrading is typically performed because of a compatibility or performance issue that occurs on a production system, and was not uncovered during initial upgrade verification on the test systems. As with the upgrade procedure *note upgrading::), perform and verify the downgrade procedure on some test systems first, before using it on a production system.

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 *note 'mysql': mysql. command-line client (connect as 'root' to ensure that you have the necessary privileges).

 File: manual.info.tmp, Node: downgrade-before-you-begin, Next: downgrade-paths, Prev: downgrading, Up: downgrading

2.11.1 Before You Begin

Review the information in this section before downgrading. Perform any recommended actions.

 File: manual.info.tmp, Node: downgrade-paths, Next: downgrading-to-previous-series, Prev: downgrade-before-you-begin, Up: downgrading

2.11.2 Downgrade Paths

 File: manual.info.tmp, Node: downgrading-to-previous-series, Next: downgrade-binary-package, Prev: downgrade-paths, Up: downgrading

2.11.3 Downgrade Notes

Before downgrading from MySQL 5.7, review the information in this section. Some items may require action before downgrading.

System Table Changes

InnoDB Changes

Logging Changes

SQL Changes

 File: manual.info.tmp, Node: downgrade-binary-package, Next: downgrade-troubleshooting, Prev: downgrading-to-previous-series, Up: downgrading

2.11.4 Downgrading Binary and Package-based Installations on Unix/Linux

This section describes how to downgrade MySQL binary and package-based installations on Unix/Linux. In-place and logical downgrade methods are described.

In-Place Downgrade

In-place downgrade involves shutting down the new MySQL version, replacing the new MySQL binaries or packages with the old ones, and restarting the old MySQL version on the existing data directory.

In-place downgrade is supported for downgrades between GA releases within the same release series.

In-place downgrade is not supported for MySQL APT, SLES, and Yum repository installations.

Note:

For some Linux platforms, MySQL installation from RPM or Debian packages includes systemd support for managing MySQL server startup and shutdown. On these platforms, note 'mysqld_safe': mysqld-safe. is not installed. In such cases, use systemd for server startup and shutdown instead of the methods used in the following instructions. See note using-systemd::.

To perform an in-place downgrade:

  1. Review the information in *note downgrade-before-you-begin::.

  2. If you use XA transactions with 'InnoDB', run note 'XA RECOVER': xa-statements. before downgrading to check for uncommitted XA transactions. If results are returned, either commit or rollback the XA transactions by issuing an note 'XA COMMIT': xa-statements. or *note 'XA ROLLBACK': xa-statements. statement.

  3. 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.

  4. Shut down the newer MySQL server. For example:

      mysqladmin -u root -p shutdown
  5. After the slow shutdown, remove the 'InnoDB' redo log files (the 'ib_logfile*' files) from the 'data' directory to avoid downgrade issues related to redo log file format changes that may have occurred between releases.

      rm ib_logfile*
  6. Downgrade the MySQL binaries or packages in-place by replacing the newer binaries or packages with the older ones.

  7. Start the older (downgraded) MySQL server, using the existing data directory. For example:

      mysqld_safe --user=mysql --datadir=/PATH/TO/EXISTING-DATADIR
  8. Run *note 'mysql_upgrade': mysql-upgrade. For example:

      mysql_upgrade -u root -p

    *note 'mysql_upgrade': mysql-upgrade. examines all tables in all databases for incompatibilities with the current version of MySQL, and attempts to repair the tables if problems are found.

  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/EXISTING-DATADIR

Logical Downgrade

Logical downgrade involves using *note 'mysqldump': mysqldump. to dump all tables from the new MySQL version, and then loading the dump file into the old MySQL version.

Logical downgrades are supported for downgrades between releases within the same release series and for downgrades to the previous release level. Only downgrades between General Availability (GA) releases are supported. Before proceeding, review *note downgrade-before-you-begin::.

Note:

For some Linux platforms, MySQL installation from RPM or Debian packages includes systemd support for managing MySQL server startup and shutdown. On these platforms, note 'mysqld_safe': mysqld-safe. is not installed. In such cases, use systemd for server startup and shutdown instead of the methods used in the following instructions. See note using-systemd::.

For MySQL APT, SLES, and Yum repository installations, only downgrades to the previous release level are supported. Where the instructions call for initializing an older instance, use the package management utility to remove MySQL 5.7 packages and install MySQL 5.6 packages.

To perform a logical downgrade:

  1. Review the information in *note downgrade-before-you-begin::.

  2. Dump all databases. For example:

      mysqldump -u root -p
        --add-drop-table --routines --events
        --all-databases --force > data-for-downgrade.sql
  3. Shut down the newer MySQL server. For example:

      mysqladmin -u root -p shutdown
  4. To initialize a MySQL 5.7 instance, use *note 'mysqld': mysqld. with the '--initialize' or '--initialize-insecure' option.

      mysqld --initialize --user=mysql
  5. Start the older MySQL server, using the new data directory. For example:

      mysqld_safe --user=mysql --datadir=/PATH/TO/NEW-DATADIR
  6. Load the dump file into the older MySQL server. For example:

      mysql -u root -p --force < data-for-upgrade.sql
  7. Run *note 'mysql_upgrade': mysql-upgrade. For example:

      mysql_upgrade -u root -p

    *note 'mysql_upgrade': mysql-upgrade. examines all tables in all databases for incompatibilities with the current version of MySQL, and attempts to repair the tables if problems are found.

  8. 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/NEW-DATADIR

 File: manual.info.tmp, Node: downgrade-troubleshooting, Prev: downgrade-binary-package, Up: downgrading

2.11.5 Downgrade Troubleshooting

If you downgrade from one release series to another, there may be incompatibilities in table storage formats. In this case, use note 'mysqldump': mysqldump. to dump your tables before downgrading. After downgrading, reload the dump file using note 'mysql': mysql. or note 'mysqlimport': mysqlimport. to re-create your tables. For examples, see note copying-databases::.

A typical symptom of a downward-incompatible table format change when you downgrade is that you cannot open tables. In that case, use the following procedure:

  1. Stop the older MySQL server that you are downgrading to.

  2. Restart the newer MySQL server you are downgrading from.

  3. Dump any tables that were inaccessible to the older server by using *note 'mysqldump': mysqldump. to create a dump file.

  4. Stop the newer MySQL server and restart the older one.

  5. Reload the dump file into the older server. Your tables should be accessible.

 File: manual.info.tmp, Node: perl-support, Prev: downgrading, Up: installing