星空网 > 软件开发 > 数据库

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_64datadir = /dataport = 3310socket = /data/mysql.sock

主要是指定了datadir

 

执行mysql_upgrade

# ./bin/mysql_upgrade -uroot -p123456 --socket=/data/mysql.sockWarning: Using a password on the command line interface can be insecure.Looking for 'mysql' as: ./bin/mysqlLooking for 'mysqlcheck' as: ./bin/mysqlcheckRunning '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                 OKmysql.db                      OKmysql.event                    OKmysql.func                     OKmysql.general_log                 OKmysql.help_category                OKmysql.help_keyword                 OKmysql.help_relation                OKmysql.help_topic                  OKmysql.host                     OKmysql.ndb_binlog_index               OKmysql.plugin                    OKmysql.proc                     OKmysql.procs_priv                  OKmysql.proxies_priv                 OKmysql.servers                   OKmysql.slow_log                   OKmysql.tables_priv                 OKmysql.time_zone                  OKmysql.time_zone_leap_second            OKmysql.time_zone_name                OKmysql.time_zone_transition             OKmysql.time_zone_transition_type          OKmysql.user                     OKRunning '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                     OKOK

 

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

mysql_upgrade examines all tables in all databases for incompatibilities with the current version of MyServer.aspx' >SQL 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

 

 

 

 

 




原标题:MySQL升级

关键词:MYSQL

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流