MySQL8.0的几个新特性
MySQL8.0的几个新特性
今天翻看MySQL8.0的官方文档的时候,看到了MySQL8.0的几个新特性,简单测了下,跟MySQL5.7做了下对比,测试的结果如下:
1、数据字典使用事务性质的表来代替之前非事务性质的表,以MySQL8.0.19和MySQL5.7.16为例,我们可以看下这两个版本的数据字典mysql库里面的相关表的存储引擎。
MySQL5.7.16
+--------------------+---------------------------------------+--------+
| mysql | columns_priv | MyISAM |
| mysql | db | MyISAM |
| mysql | engine_cost | InnoDB |
| mysql | event | MyISAM |
| mysql | func | MyISAM |
| mysql | general_log | CSV |
| mysql | gtid_executed | InnoDB |
| mysql | help_category | InnoDB |
| mysql | help_keyword | InnoDB |
| mysql | help_relation | InnoDB |
| mysql | help_topic | InnoDB |
| mysql | innodb_index_stats | InnoDB |
| mysql | innodb_table_stats | InnoDB |
| mysql | ndb_binlog_index | MyISAM |
| mysql | plugin | InnoDB |
| mysql | proc | MyISAM |
| mysql | procs_priv | MyISAM |
| mysql | proxies_priv | MyISAM |
| mysql | server_cost | InnoDB |
| mysql | servers | InnoDB |
| mysql | slave_master_info | InnoDB |
| mysql | slave_relay_log_info | InnoDB |
| mysql | slave_worker_info | InnoDB |
| mysql | slow_log | CSV |
| mysql | tables_priv | MyISAM |
| mysql | time_zone | InnoDB |
| mysql | time_zone_leap_second | InnoDB |
| mysql | time_zone_name | InnoDB |
| mysql | time_zone_transition | InnoDB |
| mysql | time_zone_transition_type | InnoDB |
| mysql | user | MyISAM |
+--------------------+---------------------------------------+--------+
MySQL8.0.19版本:
| mysql | columns_priv | InnoDB |
| mysql | component | InnoDB |
| mysql | db | InnoDB |
| mysql | default_roles | InnoDB |
| mysql | engine_cost | InnoDB |
| mysql | func | InnoDB |
| mysql | general_log | CSV |
| mysql | global_grants | InnoDB |
| mysql | gtid_executed | InnoDB |
| mysql | help_category | InnoDB |
| mysql | help_keyword | InnoDB |
| mysql | help_relation | InnoDB |
| mysql | help_topic | InnoDB |
| mysql | innodb_index_stats | InnoDB |
| mysql | innodb_table_stats | InnoDB |
| mysql | password_history | InnoDB |
| mysql | plugin | InnoDB |
| mysql | procs_priv | InnoDB |
| mysql | proxies_priv | InnoDB |
| mysql | role_edges | InnoDB |
| mysql | server_cost | InnoDB |
| mysql | servers | InnoDB |
| mysql | slave_master_info | InnoDB |
| mysql | slave_relay_log_info | InnoDB |
| mysql | slave_worker_info | InnoDB |
| mysql | slow_log | CSV |
| mysql | tables_priv | InnoDB |
| mysql | time_zone | InnoDB |
| mysql | time_zone_leap_second | InnoDB |
| mysql | time_zone_name | InnoDB |
| mysql | time_zone_transition | InnoDB |
| mysql | time_zone_transition_type | InnoDB |
| mysql | user | InnoDB |
+--------------------+---------------------------------------+--------+
可以看到,MySQL8.0.19版本中,除了slow_log和general_log表使用了CVS的存储引擎,其他表都采用Innodb的存储引擎,而MySQL5.7.16版本中的字典表还有很多都采用了MyISAM存储引擎,因为innodb表是事务安全的,支持crash_safe故障自愈,而MyISAM表不支持事务,所以从元数据的安全性来讲,MySQL8.0.19版本的元数据安全性要更好。
2、MySQL8.0.19支持DDL语句的原子性操作,要么所有的语句都成功,要么都失败,继而回滚,而MySQL5.7.16版本可能出现DDL部分成功,部分失败的现象,这句话看着比较不容易理解,举例来说明,首先来看MySQL5.7.16版本:
mysql> use test;
Database changed
mysql> create table t1 (id int);
Query OK, 0 rows affected (0.07 sec)
mysql> create table t2 like t1;
Query OK, 0 rows affected (0.03 sec)
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| t1 |
| t2 |
+----------------+
2 rows in set (0.00 sec)
mysql> drop table t1,t3;
ERROR 1051 (42S02): Unknown table 'test.t3'
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| t2 |
+----------------+
1 row in set (0.00 sec)
上图中创建了两个表t1和t2,当我们使用一个语句对t1和t3进行drop的时候,在这种情况下,MySQL5.7.16会报错test.t3表不存在,但是当我们查看结果的时候,test.t1表已经被drop掉了。这种情况比较危险,一旦出现手误的场景,某些操作是不可逆的。
而对于MySQL8.0.19来讲,在同样的场景下,表现如下:
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| t1 |
+----------------+
1 row in set (0.00 sec)
mysql> create table t2 like t1;
Query OK, 0 rows affected (0.12 sec)
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| t1 |
| t2 |
+----------------+
2 rows in set (0.00 sec)
mysql> drop table t1,t3;
ERROR 1051 (42S02): Unknown table 'test.t3'
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| t1 |
| t2 |
+----------------+
2 rows in set (0.01 sec)
可以看到,t3不存在的时候,t1并没有被drop掉,这符合我们的预期结果。
在这种情况下,MySQL8.0.19的表现好于MySQL5.7.16.
3、版本升级以前,在安装新版本的MySQL之后,MySQL服务器会在下次启动时自动升级数据字典表,此后,DBA应该手动调用mysql_upgrade来升级mysql模式中的系统表以及其中的对象。 其他架构,例如sys架构和用户架构。从MySQL 8.0.16开始,服务器执行以前由mysql_upgrade处理的任务。 在安装新的MySQL版本之后,服务器现在将在下次启动时自动执行所有必要的升级任务,而不依赖于DBA调用mysql_upgrade。
这部分内容还没有测试,后续我会补充一个在线升级MySQL8.0版本的案例,检验一下这个过程。
- MySQL 教程
- MySQL 安装
- MySQL 管理与配置
- MySQL PHP 语法
- MySQL 连接
- MySQL 创建数据库
- MySQL 删除数据库
- MySQL 选择数据库
- MySQL 数据类型
- MySQL 创建数据表
- MySQL 删除数据表
- MySQL 插入数据
- MySQL 查询数据
- MySQL where 子句
- MySQL UPDATE 查询
- MySQL DELETE 语句
- MySQL LIKE 子句
- mysql order by
- Mysql Join的使用
- MySQL NULL 值处理
- MySQL 正则表达式
- MySQL 事务
- MySQL ALTER命令
- MySQL 索引
- MySQL 临时表
- MySQL 复制表
- 查看MySQL 元数据
- MySQL 序列 AUTO_INCREMENT
- MySQL 处理重复数据
- MySQL 及 SQL 注入
- MySQL 导出数据
- MySQL 导入数据
- MYSQL 函数大全
- MySQL Group By 实例讲解
- MySQL Max()函数实例讲解
- mysql count函数实例
- MYSQL UNION和UNION ALL实例
- MySQL IN 用法
- MySQL between and 实例讲解
- 移动硬盘显示盘符但是打不开,提示加密
- GORM V2 模型定义、约定、标签
- 字符串:简单的反转还不够!
- TypeScript 实战算法系列(七):实现图的遍历
- 63. Vue MUI的基本使用
- 初学web自动化测试--笔记1
- R语言作图——Line plot with error
- Python自学成才之路 玩转虚拟环境
- 基于腾讯云的 Rust 和 WebAssembly 函数即服务
- 谷歌开源NLP模型可视化工具LIT,模型训练不再「黑箱」
- Python 装饰器填坑指南 | 最常见的报错信息、原因和解决方案
- 社区开源框架预制件相关模块:CollectManager详解
- Kettle构建Hadoop ETL实践(三):Kettle对Hadoop的支持
- 3种 Springboot 全局时间格式化方式,别再写重复代码了
- 一文搞懂CDN加速原理