Rechercher dans le manuel MySQL

2.11.1.5 Upgrading MySQL Binary or Package-based Installations on Unix/Linux

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

In-Place Upgrade

An in-place upgrade involves shutting down the old MySQL server, replacing the old MySQL binaries or packages with the new ones, restarting MySQL on the existing data directory, and running mysql_upgrade.

Note

If you are upgrading 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.

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 2.5.9, “Managing MySQL Server with systemd”.

To perform an in-place upgrade:

  1. Review the information in Section 2.11.1.1, “Before You Begin”.

  2. Ensure the upgrade readiness of your installation by completing the preliminary checks in Section 2.11.1.4, “Preparing Your Installation for Upgrade”.

  3. If you use XA transactions with InnoDB, run XA RECOVER before upgrading to check for uncommitted XA transactions. If results are returned, either commit or rollback the XA transactions by issuing an XA COMMIT or XA ROLLBACK statement.

  4. If there are encrypted InnoDB tablespaces, rotate the keyring master key by executing this statement:

    1. ALTER INSTANCE ROTATE INNODB MASTER KEY;
  5. If you normally run your MySQL server configured with innodb_fast_shutdown set to 2 (cold shutdown), configure it to perform a fast or slow shutdown by executing either of these statements:

    1. SET GLOBAL innodb_fast_shutdown = 1; -- fast shutdown
    2. SET GLOBAL innodb_fast_shutdown = 0; -- slow shutdown

    With a fast or slow shutdown, InnoDB leaves its undo logs and data files in a state that can be dealt with in case of file format differences between releases.

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

    mysqladmin -u root -p shutdown
  7. Upgrade the MySQL binaries or packages. If upgrading a binary installation, unpack the new MySQL binary distribution package. See Obtain and Unpack the Distribution. For package-based installations, install the new packages.

  8. Start the MySQL 8.0 server, using the existing data directory. For example:

    mysqld_safe --user=mysql --datadir=/path/to/existing-datadir

    If there are encrypted InnoDB tablespaces, use the --early-plugin-load option to load the keyring plugin.

    When you start the MySQL 8.0 server, it automatically detects whether data dictionary tables are present. If not, the server creates them in the data directory, populates them with metadata, and then proceeds with its normal startup sequence. During this process, the server upgrades metadata for all database objects, including databases, tablespaces, system and user tables, views, and stored programs (stored procedures and functions, triggers, Event Scheduler events). The server also removes files that previously were used for metadata storage. For example, after upgrading from MySQL 5.7 to to MySQL 8.0, you will notice that your tables no longer have .frm files.

    If this step succeeds, the server performs a cleanup:

    • In the data directory, the server creates a directory named backup_metadata_57 and moves into it files named db.opt and files with a suffix of .frm, .par, .TRG, .TRN, or .isl. (These are files previously used for metadata storage.)

      Files in the backup_metadata_57 directory retain the original file system hierarchy. For example, if t1.frm was located in the my_schema1 directory under the data directory, the server moves it to the backup_metadata_57/my_schema1 directory.

    • In the mysql database, the server renames the event and proc tables to event_backup_57 and proc_backup_57.

    If this step fails, the server reverts all changes to the data directory. In this case, you should remove all redo log files, start your MySQL 5.7 server on the same data directory, and fix the cause of any errors. Then perform another slow shutdown of the 5.7 server and start the MySQL 8.0 server to try again.

  9. After the MySQL 8.0 server starts successfully, execute mysql_upgrade:

    mysql_upgrade -u root -p

    mysql_upgrade examines all tables in all databases for incompatibilities with the current version of MySQL. It makes any remaining changes required in the mysql system database between MySQL 5.7 and MySQL 8.0, so that you can take advantage of new privileges or capabilities. mysql_upgrade also brings the Performance Schema, INFORMATION_SCHEMA, and sys schema objects up to date for MySQL 8.0.

    Note

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

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

    The first time you started the MySQL 8.0 server (in an earlier step), you may have noticed messages written to the error log regarding nonupgraded tables. If mysql_upgrade has been run successfully, there should be no such messages the second time you start the server.

 

Logical Upgrade

A logical upgrade involves exporting SQL from the old MySQL instance using a backup or export utility such as mysqldump or mysqlpump, installing the new MySQL server, and applying the SQL to your new MySQL instance.

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, 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 2.5.9, “Managing MySQL Server with systemd”.

Warning

Applying SQL extracted from a previous MySQL release to a new MySQL release may result in errors due to incompatibilities introduced by new, changed, deprecated, or removed features and capabilities. Consequently, SQL extracted from a previous MySQL release may require modification to enable a logical upgrade.

To identify incompatibilities before upgrading to the latest MySQL 8.0 release, perform the steps described in Section 2.11.1.4, “Preparing Your Installation for Upgrade”.

To perform a logical upgrade:

  1. Review the information in Section 2.11.1.1, “Before You Begin”.

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

    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.

    Important

    If you have tables that contain generated columns, use the mysqldump utility provided with MySQL 5.7.9 or higher to create your dump files. The mysqldump utility provided in earlier releases uses incorrect syntax for generated column definitions (Bug #20769542). You can use the INFORMATION_SCHEMA.COLUMNS table to identify tables with generated columns.

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

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

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

    mysqld --initialize --datadir=/path/to/8.0-datadir

    Copy the temporary 'root'@'localhost' password displayed to your screen or written to your error log for later use.

  6. Start the MySQL 8.0 server, using the new data directory. For example:

    mysqld_safe --user=mysql --datadir=/path/to/8.0-datadir
  7. Reset the root password:

    shell> mysql -u root -p
    Enter password: ****  <- enter temporary root password
    1. mysql> ALTER USER USER() IDENTIFIED BY 'your new password';
  8. Load the previously created dump file into the new MySQL server. For example:

    mysql -u root -p --force < data-for-upgrade.sql
    Note

    It is not recommended to load a dump file when GTIDs are enabled on the server (gtid_mode=ON), if your dump file includes system tables. mysqldump issues DML instructions for the system tables which use the non-transactional MyISAM storage engine, and this combination is not permitted when GTIDs are enabled. Also be aware that loading a dump file from a server with GTIDs enabled, into another server with GTIDs enabled, causes different transaction identifiers to be generated.

  9. 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 does not upgrade the contents of the help tables. For upgrade instructions, see Section 5.1.15, “Server-Side Help”.

  10. 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/8.0-datadir

Find a PHP function

Document created the 26/06/2006, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/mysql-rf-upgrade-binary-package.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.

References

  1. View the html document Language of the document:en Manuel MySQL : https://dev.mysql.com/

These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.

Contents Haut