那些从MySQL5.6升级到5.7的坑--innodb_large_prefix

简介:

前言

升级有风险,参数需谨慎

innodb_large_prefix

关于innodb_large_prefix这个参数,在之前的“MySQL之最”中有提到过,那在5.6和5.7中的表现哪里不一样呢?更直观一点,举个例子:

在5.6中的表现:

$mysql -uroot -p
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4708773
Server version: 5.6.16.12-20161009-log Source distribution
 
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
mysql> CREATE TABLE `cc` (
    ->   `id` int(11) NOT NULL AUTO_INCREMENT,
    ->   `c` varchar(255) DEFAULT NULL,
    ->   PRIMARY KEY (`id`),
    ->   KEY `idx_c` (`c`)
    -> ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4;
Query OK, 0 rows affected, 1 warning (0.01 sec)
 
mysql> show warnings;
+---------+------+---------------------------------------------------------+
| Level   | Code | Message                                                 |
+---------+------+---------------------------------------------------------+
| Warning | 1071 | Specified key was too long; max key length is 767 bytes |
+---------+------+---------------------------------------------------------+
1 row in set (0.00 sec)
 
mysql> show create table cc\G
*************************** 1. row ***************************
       Table: cc
Create Table: CREATE TABLE `cc` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `c` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_c` (`c`(191))
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4
1 row in set (0.00 sec)
mysql> show global variables like "innodb_large_prefix";
+---------------------+-------+
| Variable_name       | Value |
+---------------------+-------+
| innodb_large_prefix | OFF   |
+---------------------+-------+
1 row in set (0.00 sec)

在5.7中的表现

$mysql -uroot -p
Entry Port ==== 3313
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9304
Server version: 5.7.13.1-AliSQL-20160928-log Source distribution
 
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
root@test 02:23:11>CREATE TABLE `cc` (
    ->   `id` int(11) NOT NULL AUTO_INCREMENT,
    ->   `c` varchar(255) DEFAULT NULL,
    ->   PRIMARY KEY (`id`),
    ->   KEY `idx_c` (`c`)
    -> ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4;
Query OK, 0 rows affected (0.00 sec)
 
root@test 02:25:46>show warnings;
Empty set (0.00 sec)
 
root@test 02:26:17>show global variables like "innodb_large_prefix";
+---------------------+-------+
| Variable_name       | Value |
+---------------------+-------+
| innodb_large_prefix | ON    |
+---------------------+-------+
1 row in set (0.00 sec)
 
root@test 02:28:43>

结论

如果想在5.6和5.7统一的话,修改innodb_large_prefix这个参数同时为ON或者OFF就可以了

相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。   相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情: https://www.aliyun.com/product/rds/mysql 
目录
相关文章
Java(七):List和Map互转
Java(七):List和Map互转
1049 0
|
JSON PHP 开发工具
PHP Monolog 日志的使用
PHP Monolog 日志的使用
1655 0
|
存储 网络协议 关系型数据库
麒麟 arm64 环境编译部署 mysql
麒麟 arm64 环境编译部署 mysql
1484 0
|
弹性计算 Java 网络协议
……企业搭建门户网站需要考虑的事情就很多了?
企业门户网站不同于普通网站,它不仅是品牌形象的展示,还集品牌宣传、销售、服务、互动、数据营销等多功能于一体。企业搭建门户需考虑多地访客的访问速度、定制开发及高昂成本。为解决这些问题,中小企业转向云服务,如阿里云提供的解决方案,利用云效流水线自动化构建和发布,通过ROS快速创建ECS,结合DNS解析和CDN加速,实现高效低成本的部署。此方案简化了上线的流程,但完整的开发还包括设计、开发、测试等环节在本解决方案中没有体现。
894 1
……企业搭建门户网站需要考虑的事情就很多了?
|
Java jenkins 持续交付
jenkins构建jar包为镜像并上传到docker仓库
jenkins构建jar包为镜像并上传到docker仓库
716 0
|
IDE 测试技术 开发工具
Python自动化测试实战系列之WiFi测试一
用Python设计一个自动化测试WiFi射频指标的脚本工具
1051 0

热门文章

最新文章