iis服务器助手广告广告
返回顶部
首页 > 资讯 > 数据库 >2.11.1 Mysql 升级 Upgrade Methods
  • 821
分享到

2.11.1 Mysql 升级 Upgrade Methods

2024-04-02 19:04:59 821人浏览 泡泡鱼
摘要

1.升级方法 In-Place Upgrade: (就地升级)Involves shutting down the old Mysql version, replacing the

1.升级方法

  1. 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.
  2. 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.

 

2.升级路径

  1. 仅支持General Availability(GA)版本之间的升级
  2. 从5.6到5.7是支持的,升级的下一个版本之前建议升级到最新的版本,如先升级的5.6的最后一个版本,再升级的5.7
  3. 不支持跳版本升级, 如从5.5 到 5.7
  4. 小版本升级是支持的,如5.7.x 到 5.7.y

Upgrade within a release series is supported

 

3.开始之前

  1. 备份,包含系统库、系统表
  2. 查看不兼容的改变,see Features Removed in MySQL 5.7.
  3. 查看 Section 2.11.1.2, “Changes Affecting Upgrades to MySQL 5.7”. This section describes changes that may require action before or after upgrading.这部分描述了升级前后可能需要的执行变化。
  1. 如果你使用了replication复制,查看Section 16.4.3, “Upgrading a Replication Setup”.
  1. 如果你使用了 InnoDB的  XA transactions,在升级之前运行“XA RECOVER”来检查未提交的Xa事务,如果有结果返回,需要执行XA COMMIT or XA ROLLBACK语句来提交或回滚Xa事务

 

 

In-Place Upgrade

To perfORM an in-place upgrade:

  1. Review the changes described in Section 2.11.1.2, “Changes Affecting Upgrades to MySQL 5.7” for steps to be performed before upgrading.
  2. 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.

 

  1. Shut down the old MySQL Server. For example:
    mysqladmin -u root -p shutdown

 

  1. Upgrade the MySQL binary installation or packages. If upgrading a binary installation, unpack the new MySQL binary distribution package. See Obtain and Unpack the Distribution. For package-based installations, replace the old packages with the new ones.
    Note
    For supported linux distributions, the preferred method for replacing the MySQL packages is to use the MySQL software repositories; see Section 2.11.1.3, “Upgrading MySQL with the MySQL Yum Repository”, Section 2.11.1.4, “Upgrading MySQL with the MySQL APT Repository”, or Upgrading MySQL with the MySQL SLES Repository for instructions.

 

  1. Start the MySQL 5.7 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

 

  1. 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.11, “Server-Side Help”.

 

  1. 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 Upgrade

 

  1. Review the changes described in Section 2.11.1.2, “Changes Affecting Upgrades to MySQL 5.7” for steps to be performed before upgrading.
  2. Export your existing data from the previous MySQL version:
    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.

 

  1. Shut down the old MySQL server. For example:
    mysqladmin -u root -p shutdown
  2. Install MySQL 5.7. For installation instructions, see Chapter 2, Installing and Upgrading MySQL.
  3. Initialize a new data directory, as described at Section 2.10.1, “Initializing the Data Directory”. For example:
    mysqld --initialize --datadir=/path/to/5.7-datadir

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

  1. Start the MySQL 5.7 server, using the new data directory. For example:
    mysqld_safe --user=mysql --datadir=/path/to/5.7-datadir

 

  1. Reset the root password:

shell> mysql -u root -p
Enter password: ****  <- enter temporary root password

mysql> ALTER USER USER() IDENTIFIED BY 'your new password';

 

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

 

  1. 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.11, “Server-Side Help”.

  1. 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/5.7-datadir

 

Upgrade Troubleshooting

 

  1. If problems occur, such as that the new mysqld server does not start, verify that you do not have an old my.cnf file from your previous installation. You can check this with the --print-defaults option (for example, mysqld --print-defaults). If this command displays anything other than the program name, you have an active my.cnf file that affects server or client operation.
  2. If, after an upgrade, you experience problems with compiled client programs, such as Commands out of sync or unexpected core dumps, you probably have used old header or library files when compiling your programs. In this case, check the date for your mysql.h file and libmysqlclient.a library to verify that they are from the new MySQL distribution. If not, recompile your programs with the new headers and libraries. Recompilation might also be necessary for programs compiled against the shared client library if the library major version number has changed (for example, from libmysqlclient.so.15 to libmysqlclient.so.16).
  3. If you have created a user-defined function (UDF) with a given name and upgrade MySQL to a version that implements a new built-in function with the same name, the UDF becomes inaccessible. To correct this, use DROP FUNCTION to drop the UDF, and then use CREATE FUNCTION to re-create the UDF with a different nonconflicting name. The same is true if the new version of MySQL implements a built-in function with the same name as an existing stored function. See Section 9.2.4, “Function Name Parsing and Resolution”, for the rules describing how the server interprets references to different kinds of functions.
您可能感兴趣的文档:

--结束END--

本文标题: 2.11.1 Mysql 升级 Upgrade Methods

本文链接: https://www.lsjlt.com/news/48769.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • oracle怎么查询当前用户所有的表
    要查询当前用户拥有的所有表,可以使用以下 sql 命令:select * from user_tables; 如何查询当前用户拥有的所有表 要查询当前用户拥有的所有表,可以使...
    99+
    2024-05-15
    oracle
  • oracle怎么备份表中数据
    oracle 表数据备份的方法包括:导出数据 (exp):将表数据导出到外部文件。导入数据 (imp):将导出文件中的数据导入表中。用户管理的备份 (umr):允许用户控制备份和恢复过程...
    99+
    2024-05-15
    oracle
  • oracle怎么做到数据实时备份
    oracle 实时备份通过持续保持数据库和事务日志的副本来实现数据保护,提供快速恢复。实现机制主要包括归档重做日志和 asm 卷管理系统。它最小化数据丢失、加快恢复时间、消除手动备份任务...
    99+
    2024-05-15
    oracle 数据丢失
  • oracle怎么查询所有的表空间
    要查询 oracle 中的所有表空间,可以使用 sql 语句 "select tablespace_name from dba_tablespaces",其中 dba_tabl...
    99+
    2024-05-15
    oracle
  • oracle怎么创建新用户并赋予权限设置
    答案:要创建 oracle 新用户,请执行以下步骤:以具有 create user 权限的用户身份登录;在 sql*plus 窗口中输入 create user identified ...
    99+
    2024-05-15
    oracle
  • oracle怎么建立新用户
    在 oracle 数据库中创建用户的方法:使用 sql*plus 连接数据库;使用 create user 语法创建新用户;根据用户需要授予权限;注销并重新登录以使更改生效。 如何在 ...
    99+
    2024-05-15
    oracle
  • oracle怎么创建新用户并赋予权限密码
    本教程详细介绍了如何使用 oracle 创建一个新用户并授予其权限:创建新用户并设置密码。授予对特定表的读写权限。授予创建序列的权限。根据需要授予其他权限。 如何使用 Oracle 创...
    99+
    2024-05-15
    oracle
  • oracle怎么查询时间段内的数据记录表
    在 oracle 数据库中查询指定时间段内的数据记录表,可以使用 between 操作符,用于比较日期或时间的范围。语法:select * from table_name wh...
    99+
    2024-05-15
    oracle
  • oracle怎么查看表的分区
    问题:如何查看 oracle 表的分区?步骤:查询数据字典视图 all_tab_partitions,指定表名。结果显示分区名称、上边界值和下边界值。 如何查看 Oracle 表的分区...
    99+
    2024-05-15
    oracle
  • oracle怎么导入dump文件
    要导入 dump 文件,请先停止 oracle 服务,然后使用 impdp 命令。步骤包括:停止 oracle 数据库服务。导航到 oracle 数据泵工具目录。使用 impdp 命令导...
    99+
    2024-05-15
    oracle
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作