zoukankan      html  css  js  c++  java
  • MySQL升级

    MySQL的升级相对来说还是比较简单的。

    它支持两种方式的升级:

    原地升级(In-place Upgrade)

    关闭数据库,替换旧的二进制文件,重启数据库,执行mysql_upgrade

    逻辑升级(Logical Upgrade)

    用mysqldump导出数据,安装新的数据库版本,将数据导入到新的数据库中,执行mysql_upgrade

    但是MySQL版本众多,不仅有各种大版本,譬如5.1,5.5,5.6,5.7,同一个大版本中也会有各种小版本。

    那么官方支持怎么的升级路径呢?

    1. 同一个大版本中的小版本升级,譬如5.6.25到5.6.31。

    2. 跨版本升级,但只支持跨一个版本升级,譬如5.5到5.6,5.6到5.7。

    3. 不支持跨版本的直接升级,譬如直接从5.1到5.6,可以先从5.1升级到5.5,再从5.5升级到5.6。

    以上均是指MySQL的GA版本,从非GA版本到GA版本的升级并不支持,譬如5.6.9到5.6.10,因为前者并不是一个GA版本。

    关于版本信息,可参考官方说明

    http://downloads.mysql.com/archives/community/

    下面演示一下原地升级

    待升级版本MySQL 5.5.30

    目标版本MySQL 5.6.32

    设置参数

    mysql> set global innodb_fast_shutdown=0;
    Query OK, 0 rows affected (0.00 sec)

    innodb_fast_shutdown参数有三个值

    0: 在数据库关闭的时候,会执行purge操作和change buffer合并,也称为“show shutdown”

    1: 默认值,在数据库关闭的时候,会跳过purge操作和change buffer合并,也称为“fast shutdown”

    2: 在数据库关闭的时候,只是flush log,然后执行关闭操作。在恢复的时候可能需要较长时间的crash recovery

    彻底关闭数据库

    # ./bin/mysqladmin shutdown -uroot -p123456 --socket /data/mysql.sock

    更新MySQL二进制文件

    在这里,我直接使用新的二进制压缩包

    使用新的MySQL启动

    此时datadir指向原来的数据目录

    # ./bin/mysqld_safe  --defaults-file=/usr/test/mysql-5.6.32-linux-glibc2.5-x86_64/my.cnf --user=mysql --ledir=/usr/test/mysql-5.6.32-linux-glibc2.5-x86_64/bin  &

    其中,配置文件中的内容如下

    [mysqld]
    basedir = /usr/test/mysql-5.6.32-linux-glibc2.5-x86_64
    datadir = /data
    port = 3310
    socket = /data/mysql.sock

    主要是指定了datadir

    执行mysql_upgrade

    # ./bin/mysql_upgrade -uroot -p123456 --socket=/data/mysql.sock
    Warning: Using a password on the command line interface can be insecure.
    Looking for 'mysql' as: ./bin/mysql
    Looking for 'mysqlcheck' as: ./bin/mysqlcheck
    Running 'mysqlcheck' with connection arguments: '--socket=/data/mysql.sock' 
    Warning: Using a password on the command line interface can be insecure.
    Running 'mysqlcheck' with connection arguments: '--socket=/data/mysql.sock' 
    Warning: Using a password on the command line interface can be insecure.
    mysql.columns_priv                                 OK
    mysql.db                                           OK
    mysql.event                                        OK
    mysql.func                                         OK
    mysql.general_log                                  OK
    mysql.help_category                                OK
    mysql.help_keyword                                 OK
    mysql.help_relation                                OK
    mysql.help_topic                                   OK
    mysql.host                                         OK
    mysql.ndb_binlog_index                             OK
    mysql.plugin                                       OK
    mysql.proc                                         OK
    mysql.procs_priv                                   OK
    mysql.proxies_priv                                 OK
    mysql.servers                                      OK
    mysql.slow_log                                     OK
    mysql.tables_priv                                  OK
    mysql.time_zone                                    OK
    mysql.time_zone_leap_second                        OK
    mysql.time_zone_name                               OK
    mysql.time_zone_transition                         OK
    mysql.time_zone_transition_type                    OK
    mysql.user                                         OK
    Running 'mysql_fix_privilege_tables'...
    Warning: Using a password on the command line interface can be insecure.
    Running 'mysqlcheck' with connection arguments: '--socket=/data/mysql.sock' 
    Warning: Using a password on the command line interface can be insecure.
    Running 'mysqlcheck' with connection arguments: '--socket=/data/mysql.sock' 
    Warning: Using a password on the command line interface can be insecure.
    test.test                                          OK
    OK

    关于mysql_upgrade的作用,官方文档说明如下:

    mysql_upgrade examines all tables in all databases for incompatibilities with the current version of MySQL Server. mysql_upgrade also upgrades the system tables so that you can take advantage of new privileges or capabilities that might have been added.
    
    If mysql_upgrade finds that a table has a possible incompatibility, it performs a table check and, if problems are found, attempts a table repair. 

    主要是升级系统表和修复不兼容的表。

    参考

    1. http://dev.mysql.com/doc/refman/5.6/en/upgrading.html

     

  • 相关阅读:
    Tarjan算法求双连通分量
    Tarjan
    前端技术实现js图片水印
    记录一下ionic canvas图片,还有canvas里面的图片跨域的问题
    ionic cordova screenshot 使用和操作
    关于ionic2 更新到ionic3 后组件不能用的解决方案
    背景图处理,这是个好东西记录一下
    radio样式的写法,单选和多选如何快速的改变默认样式,纯CSS,
    ionic使用cordova插件中的Screenshot截图分享功能
    ionic中执行pop返回上一个页面,还需要执行操作
  • 原文地址:https://www.cnblogs.com/ivictor/p/5776349.html
Copyright © 2011-2022 走看看