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版本的案例,检验一下这个过程。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值