MySQL 8 Cookbook
上QQ阅读APP看书,第一时间看更新

Logical Upgrades

Here is an outline of the steps:

  1. Export existing data from the old MySQL version using mysqldump
  2. Install the new MySQL version
  3. Load the dump file into the new MySQL version
  4. Run the mysql_upgrade utility

Here are the detailed steps:

  1. You need to take a logical backup of the database (refer to Chapter 7, Backups for a quicker backup called mydumper):
shell> mysqldump -u root -p --add-drop-table --routines --events --all-databases --ignore-table=mysql.innodb_table_stats --ignore-table=mysql.innodb_index_stats --force > data-for-upgrade.sql
  1. Shut down the MySQL server (refer to the Starting or Stopping MySQL 8 section).
  2. Install the new MySQL version (refer to the methods mentioned in the In-place upgrades section).
  3. Start the MySQL server (refer to the Starting or Stopping MySQL 8 section).
  4. Reset the temporary root password:
shell> mysql -u root -p
Enter password: **** (enter temporary root password from error log)

mysql> ALTER USER USER() IDENTIFIED BY 'your new password';
  1. Restore the backup (this may take a long time depending up on the size of the backup). Refer to Chapter 8, Restoring Data for a quick restoration method called myloader:
shell> mysql -u root -p --force < data-for-upgrade.sql
  1. Run the mysql_upgrade utility:
shell> sudo mysql_upgrade -u root -p
  1. Restart the MySQL server (refer to the Starting or Stopping MySQL 8 section).