Upgrading MySQL
Supported Upgrade Methods
In-place upgrade
Involves shutting down the old MySQL version, replacing the old MySQL binaries or packages with the new ones, restarting MySQL on the existing data directory, and running mysql_upgrade.
Logical Upgrade
Involves exporting existing data from the old MySQL version using mysqldump, installing the new MySQL version, loading the dump file into the new MySQL version, and running mysql_upgrade
Performing an In-place Upgrade
Backup the databases before you begin and read the upgrade notes for the specific version.
Configure MySQL to perform a slow shutdown by setting
innodb_fast_shutdownto0.shell> bin/mysql -u root -p password --execute="set global innodb_fast_shutdown=0"Shut down the old MySQL server
shell> bin/mysqladmin -u root -p password shutdownUpgrade the MySQL binaries or packages in place, replacing the old binaries or packages with the new ones.
Start the MySQL server, using the existing data directory.
Run
mysql_upgrade.
Performing a Logical Upgrade
Export your existing data from the previous MySQL version:
shell> mysqldump --add-drop-table --routines --events -> --all-databases --force > data-for-upgrade.sqlShut down the old MySQL server
shell> bin/mysqladmin -u root -p password shutdownInstall MySQL 5.7.
Initialize a new data directory
shell> mysqld --initialize --datadir=/path/to/5.7-datadirCopy the temporary 'root'@'localhost' password printed to your screen or written to your error log for later use.Start the MySQL 5.7 server, using the new data directory.
shell> bin/mysqld_safe --user=mysql --datadir=/path/to/5.7-datadirReset the root password
shell> mysql -u root -p Enter password:**<- enter temporary root passwordmysql> ALTER USER USER() IDENTIFIED BY 'your new password';Load the previously created dump file into the new MySQL server.
shell> bin/mysql -u root -p password --execute="source data-for-upgrade.sql" --forceRun mysql_upgrade.
shell> bin/mysql_upgrade -u root -p passwordConfigure MySQL to perform a slow shutdown by setting innodb_fast_shutdown to 0.
shell> bin/mysql -u root -p password --execute="set global innodb_fast_shutdown=0"Shut down and restart the MySQL server to ensure a clean shutdown and startup.
shell> bin/mysqladmin -u root -p password shutdown shell> bin/mysqld_safe --user=mysql --datadir=/path/to/5.7-datadir