从参数变化解读 MySQL 8.2.0 发版说明

↑ 关注“少安事务所”公众号,欢迎⭐收藏,不错过精彩内容~

日前,MySQL 8.2.0 创新版本已正式上线,并提供安装包下载,但 docker 镜像尚未更新。

在 MySQL 8.1.0 刚发版时也做过分析,欢迎阅读: 重磅!MySQL 8.1.0 已来!

本文将通过 MySQL 启动选项和系统参数的变更情况,来深入了解 8.2.0 都有哪些变化。

启动 MySQL 8.2.0

这一小节不是本文的重点,我们快速推进。

从官网直接下载二进制包,并初始化运行。

  • 初始化日志:
[shawnyan@centos7 ~]$ sudo /usr/local/mysql/bin/mysqld --initialize-insecure
2023-10-26T01:57:36.185664Z 0 [System] [MY-015017] [Server] MySQL Server Initialization - start.
2023-10-26T01:57:36.187344Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.2.0) initializing of server in progress as process 119963
2023-10-26T01:57:36.194573Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-10-26T01:57:36.712452Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-10-26T01:57:38.681960Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2023-10-26T01:57:42.299632Z 0 [System] [MY-015018] [Server] MySQL Server Initialization - end.
  • 服务器启动日志:
[mysql@centos7 ~]$ /usr/local/mysql/bin/mysqld
2023-10-26T02:00:07.525736Z 0 [System] [MY-015015] [Server] MySQL Server - start.
2023-10-26T02:00:08.462689Z 0 [System] [MY-010116] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.2.0) starting as process 120743
2023-10-26T02:00:08.473638Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-10-26T02:00:09.377582Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-10-26T02:00:09.757717Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-10-26T02:00:09.757776Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2023-10-26T02:00:09.822331Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /tmp/mysqlx.sock
2023-10-26T02:00:09.822417Z 0 [System] [MY-010931] [Server] /usr/local/mysql/bin/mysqld: ready for connections. Version: '8.2.0'  socket: '/tmp/mysql.sock'  port: 3306  MySQL Community Server - GPL.

2023-10-26T02:00:22.899823Z 8 [Warning] [MY-013360] [Server] Plugin mysql_native_password reported: ''mysql_native_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'

为了便于测试,这里直接将 root 用户密码设为空,并直接运行 mysqld 服务。

  • 登陆 MySQL 并查看版本信息:
alt

删除的参数 (3)

1. abort-slave-event-count

The deprecated server startup options --abort-slave-event-count and --disconnect-slave-event-count, deprecated in MySQL 8.0, have been removed in this release. Attempting to start mysqld with either of these options now results in an error.

abort_slave_event_count / disconnect_slave_event_count 这两个启动参数在之前的版本中用做测试,并非真的生产环境参数。

从 8.0.29 版本开始,被标记为废弃状态,从 8.2.0 开始,正式被移除。

2. disconnect-slave-event-count

同上。

3. expire-logs-days

expire_logs_days 参数用于设定二进制日志保留天数,从 8.2.0 开始,正式被移除。

从 MySQL 8.0.1 开始,新增参数 binlog_expire_logs_seconds,以秒为单位控制二进制日志的保留时长。

默认值为 2592000 ,即 30 天。最大值为 4294967295 ,即 unsigned int 最大值,约 138 年。

在 MariaDB 中,从 10.6.1 开始引入 binlog_expire_logs_seconds 参数,但默认值为 0 ,需要自己进行设定。

变更值的参数 (6)

1. master-retry-count

master_retry_count 参数用于设定复制连接超时后,重试连接的最大次数。 在 8.2.0 默认值为 10 ,而 8.0.35 的默认值为 86400 ,这一变更是从 8.1.0 开始的。

需要注意的是,创建复制的语法 change master to 已经废弃,改为 change replication source to

2. optimizer-switch (hash_set_operations=on)

从 8.2.0 开始, optimizer_switch 中新增了一个控制标记 hash_set_operations,默认值为 on

用于对集合操作(包括 EXCEPT 和 INTERSECT)进行哈希表优化,这种优化用于哈希的内存量可以使用 set_operations_buffer_size 系统变量来控制。

系统变量 set_operations_buffer_size 是 MySQL 8.2.0 新引入的,下面会再介绍。

3. performance-schema-error-size

performance_schema_error_size 表示数据库错误码的数量,在 MySQL 8.0.35 中,默认值为 5307 ,而在 MySQL 8.2.0 中,变更为 5377 。

mysql> SELECT version(),count(*) FROM performance_schema.events_errors_summary_global_by_error;
+-----------+----------+
| version() | count(*) |
+-----------+----------+
| 8.2.0     |     5377 |
+-----------+----------+
1 row in set (0.00 sec)

源码中的定义如下:

static Sys_var_long Sys_pfs_error_size(
    "performance_schema_error_size""Number of server errors instrumented.",
    READ_ONLY GLOBAL_VAR(pfs_param.m_error_sizing), CMD_LINE(REQUIRED_ARG),
    VALID_RANGE(01024 * 1024), DEFAULT(PFS_MAX_GLOBAL_SERVER_ERRORS),
    BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES)
;

4. performance-schema-max-memory-classes

performance_schema_max_memory_classes 是全局只读参数,表示 memory instruments 的最大数量。

在 MySQL 8.0.35 中,默认值为 450 ,但在 MySQL 8.2.0 中变为 470 ,不过官方文档尚未更新。

已在 MySQL Bugs 网站提交相关 bug:

https://bugs.mysql.com/bug.php?id=112839

5. performance-schema-max-rwlock-classes

performance_schema_max_rwlock_classes 是全局只读参数,表示 rwlock instruments 的最大数量。

在 MySQL 8.0.35 中,默认值为 60 ,但在 MySQL 8.2.0 中变为 100 。

6. performance-schema-max-statement-classes

performance_schema_max_statement_classes 是全局只读参数,表示 statement instruments 的最大数量。

默认值是在服务器构建时根据客户机/服务器协议中的命令数量和服务器支持的SQL语句类型数量计算的。

在 MySQL 8.0.35 中,默认值为 219 ,而在 MySQL 8.2.0 中变为 220 。

那么,多的1个是从哪来的呢?

从相关代码提交记录可以看到描述:

https://github.com/mysql/mysql-server/commit/eb7dd6c6c10c0437658caa7b9c7716c0468582fa WL#15426: Implement SHOW PARSE_TREE

Implemented a SHOW PARSE_TREE statement in debug builds to display the JSON-formatted parse tree for a SELECT statement. This statement is not supported in release builds, and is available only in debug builds, or by compiling the server using -DWITH_SHOW_PARSE_TREE. (WL #15426)

从 MySQL 8.1.0 开始,引入新 SQL 语句, show parse_tree 用来调试 select 语句,并以 json 格式展示。 需要注意的是,该参数只能用于 Debug 模式,所以官方下载的正式安装包是无法使用该语法的,否则会报语法错误。

mysql> SHOW PARSE_TREE select 1;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PARSE_TREE select 1' at line 1

新增的参数 (7)

1. mysql-native-password

MySQL 中创建用户时默认的密码插件已经变更为 caching_sha2_password,但目前仍然支持使用 mysql_native_password,该参数就是控制服务器启动时,是否启用该密码插件。

在 8.1.0 的发版说明中有如下一段描述:

https://dev.mysql.com/doc/relnotes/mysql/8.1/en/news-8-1-0.html

The mysql_native_password authentication plugin now is deprecated and subject to removal in a future version of MySQL. CREATE USER, ALTER USER, and SET PASSWORD operations now insert a deprecation warning into the server error log if an account attempts to authenticate using mysql_native_password as an authentication method. (Bug #35336317)

具体演示如下:

mysql> create user shawnyan identified with mysql_native_password by '1';
Query OK, 0 rows affected (0.00 sec)

日志中会提示该插件已弃用,请用 caching_sha2_password 代替。

2023-10-26T09:04:32.364529Z 12 [Warning] [MY-013360] [Server] Plugin mysql_native_password reported: ''mysql_native_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'

2. ndb-mgm-tls

启动选项 ndb-mgm-tls/ndb-tls-search-path 是 MySQL 8.2.0 新引入的,为 NDB 引擎增加 TLS 相关选项。

但由于文档中暂无相关参数描述,而且官网公开的 worklog 不再更新,所以无法查阅到具体的功能描述,仅能通过社区版的代码提交记录窥视一二。

WL#15524 post-push fixes (2nd set)
WL#15524 post-push fixes
WL#15524 Patch #17 Run more existing MTR tests with TLS
WL#15524 Patch #16 Use TLS for Event Listener
WL#15524 Patch #15 Visbility
WL#15524 Patch #14 Add MGM TLS support to all remaining tools
WL#15524 patch #13 ndb_waiter and new MTR tests
WL#15524 Patch #12 MGM TLS in API Nodes, mysqld, and Cluster/J
WL#15524 Patch #11 Use MGM TLS in TransporterRegistry and MgmtSrvr
WL#15524 Patches #9 and #10: --ndb-mgm-tls in ndbd and ndb_mgmd
WL#15524 Patch #8 TLS options in ndb_mgm
WL#15524 Patch #7 Add --ndb-mgm-tls option to ndb_sign_keys
WL#15524 Patch #6 Command authorization in MGM client
WL#15524 Patch #5 Command authorization in MGM server
WL#15524 Patch #4 MGM TLS Configuration
WL#15524 Patch #3 Use TLS for upgraded transporter
WL#15524 Patch #2 TLS-safe upgrade of mgm socket to transporter
WL#15524 Patch #1 "START TLS" for management API

以及,从源码中,可以看到这个选项提供了三个选项值,分别是 relaxed,strict,deferred,默认值为 relaxed

/* ndb_mgm uses an extended form of the --ndb-mgm-tls enum, which accepts
   an extra option, "disabled"
*/

static const char * tls_names[] = { "relaxed""strict""deferred"nullptr };

3. ndb-tls-search-path

用于存放 NDB 集群 TLS 私钥的目录。 具体内容,同上。

4. performance-schema-max-meter-classes

performance_schema_max_meter_classes 是全局只读系统变量,从 MySQL 8.2.0 开始引入,表示 meter instruments 可被创建的最大数量。

5. performance-schema-max-metric-classes

performance_schema_max_metric_classes 是全局只读系统变量,从 MySQL 8.2.0 开始引入,表示 metric instruments 可被创建的最大数量。

performance_schema_max_meter_classes / performance_schema_max_metric_classes 这两个变量是一个 worklog 里增加的,用于服务器的遥测指标接口。

另外,命令很相似,一个是 meter,另一个是 metric,需要注意区分。

6. set-operations-buffer-size

set_operations_buffer_size 可以动态调整,默认值为 256K,最大可以调整到 1GB,从 MySQL 8.2.0 开始引入。

在上面的 optimizer-switch (hash_set_operations=on) 部分已经介绍过。

相关文档参见:

https://dev.mysql.com/doc/refman/8.2/en/server-system-variables.html#sysvar_set_operations_buffer_size

7. tls-certificates-enforced-validation

tls_certificates_enforced_validation 表示在数据库启动时,强制校验 SSL 证书是否有效,如果设定为 TRUE ,那么数据库在发现无效证书时将停止启动,其默认值为 OFF

总结

MySQL 8.2.0 启动选项和系统变量的变化多达 16 项,还有很多系统状态变量文本没有列举。

alt

MySQL 8.2.0 是 MySQL 变更发版模型后的第二个版本,是创新版本 (Innovation Release),不建议部署到生产环境。

更多精彩

[MySQL]

[Oracle]

-- / END / --

foot.png

如果这篇文章为你带来了灵感或启发,就请帮忙点『赞』or『在看』or『转发』吧,感谢!(๑˃̵ᴗ˂̵)

本文由 mdnice 多平台发布

  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
MySQL 8.2.0是一个关系型数据库管理系统,它是MySQL数据库的一个重要版本。MySQL是一种开源的数据库系统,被广泛应用于互联网和企业级应用中。 MySQL 8.2.0带来了许多功能和改进。其中一项主要的改进是对JSON数据类型的支持。使用JSON数据类型,可以在数据库中存储和查询JSON格式的数据。这样可以更方便地处理复杂的数据结构,并且可以更快地检索和操作JSON数据。 此外,MySQL 8.2.0还引入了窗口函数的支持。窗口函数是一种在查询中应用于特定窗口范围的函数,例如计算特定行与其他行之间的差异。窗口函数使得在不同行之间进行聚合、排序和排名等操作变得更加灵活和高效。 MySQL 8.2.0还改进了其安全性功能。它提供了更细粒度的权限控制,使得管理员可以更好地管理和控制用户对数据库的访问。另外,它还增强了密码安全性,支持更强的密码加密算法,提供更好的防护机制。 此外,MySQL 8.2.0还改善了性能和可伸缩性。它通过引入新的索引算法和查询优化技术来提高查询性能。此外,它还支持更高级的多线程和并发控制,提供更好的并发处理能力和可伸缩性。 总之,MySQL 8.2.0是一个功能强大、安全可靠、性能高效的数据库管理系统。它为开发人员和管理员提供了更多的工具和功能,使得他们可以更好地处理和管理数据。无论是小型网站还是大型企业级应用,MySQL 8.2.0都是一个可靠的选择。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值