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 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.
For some Linux platforms, MySQL installation from RPM or Debian packages includes systemd support for managing MySQL server startup and shutdown. On these platforms, 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 Section 7.10, “Managing MySQL Server with systemd”.
To perform an in-place downgrade:
Review the information in Section 11.1, “Before You Begin”.
If you use XA transactions with
InnoDB
, runXA RECOVER
before downgrading to check for uncommitted XA transactions. If results are returned, either commit or rollback the XA transactions by issuing anXA COMMIT
orXA ROLLBACK
statement.Configure MySQL to perform a slow shutdown by setting
innodb_fast_shutdown
to0
. 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.Shut down the newer MySQL server. For example:
mysqladmin -u root -p shutdown
After the slow shutdown, remove the
InnoDB
redo log files (theib_logfile*
files) from thedata
directory to avoid downgrade issues related to redo log file format changes that may have occurred between releases.rm ib_logfile*
Downgrade the MySQL binaries or packages in-place by replacing the newer binaries or packages with the older ones.
Start the older (downgraded) MySQL server, using the existing data directory. For example:
mysqld_safe --user=mysql --datadir=/path/to/existing-datadir
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, and attempts to repair the tables if problems are found.
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 involves using 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 Section 11.1, “Before You Begin”.
For some Linux platforms, MySQL installation from RPM or Debian packages includes systemd support for managing MySQL server startup and shutdown. On these platforms, 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 Section 7.10, “Managing MySQL Server with 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:
Review the information in Section 11.1, “Before You Begin”.
Dump all databases. For example:
mysqldump -u root -p --add-drop-table --routines --events --all-databases --force > data-for-downgrade.sql
Shut down the newer MySQL server. For example:
mysqladmin -u root -p shutdown
To initialize a MySQL 5.7 instance, use mysqld with the
--initialize
or--initialize-insecure
option.mysqld --initialize --user=mysql
Start the older MySQL server, using the new data directory. For example:
mysqld_safe --user=mysql --datadir=/path/to/new-datadir
Load the dump file into the older MySQL server. For example:
mysql -u root -p --force < data-for-upgrade.sql
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, and attempts to repair the tables if problems are found.
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