支持向量的 MySQL 9.0 已发布,我却看不懂 MySQL 的骚操作了!

4天前 15.4k 0

前 言

2024 年第三季度 MySQL 新版本发布了,北京时间 7 月 1 日 傍晚时分,MySQL 官方发布了 MySQL 9.0 新的创新版本,以及 LTS 长周期版本 8.4.1 和 MySQL8 系列的 MySQL8.0.38 版本。但是 MySQL 官方却没有发布 MySQL9 的官方文档以及《What Is New in MySQL 9.0》,也没有《MySQL 9.0 Release Notes》,这三个文档肯定是每个 MySQL 新版本发布必读的文档。

支持向量的 MySQL 9.0 已发布,我却看不懂 MySQL 的骚操作了!-1

(https://dev.mysql.com/downloads/mysql/)

等待第二日,也就是北京时间 7 月 3 日凌晨才发布了官方文档,《What Is New in MySQL 9.0》和《MySQL 9.0 Release Notes》。于是赶紧去翻翻看,实在是大跌眼镜,MySQL 9.0 火出圈了,都在讨论 9.0 新版本,原厂大佬也说支持 vector 向量数据类型了,但是不管是使用全篇搜索还是查看标题从这三个文档中看不到关于 vector 向量相关的内容,但是根据圈内传出来的 MySQL9.0 截图发现是支持向量数据类型的,查看官方文档中关于数据类型的介绍也没有 vector 向量数据类型。这就很让人莫不着头脑了,官方文档的介绍更是简单的和没说一样,看不到什么新特性?这是在挤牙膏吗?那为啥又能清楚看到支持向量数据类型呢?有知道的大佬来评论区聊聊呀!

MySQL LTS 长周期版本和 Innovation 创新版本

MySQL 的发布模式主要分为两个方面: LTS(长期支持)和 Innovation 创新版本。所有 LTS 和创新版本都包含错误和安全修复,被视为生产级质量。

支持向量的 MySQL 9.0 已发布,我却看不懂 MySQL 的骚操作了!-2

  • MySQL LTS 版本

如果您的环境需要一组稳定的特性和较长的支持周期,一般情况下有八年的长周期支持,例如:8.0.X 以及 8.4.X 以及 9.7.X 。

行为:这些版本只包含必要的修复,以减少与数据库软件行为变化相关的风险。在 LTS版本中没有删除。功能只能在第一个 LTS 版本(如 8.4.0 LTS)中删除(和添加),之后则不能删除。

支持:LTS 系列遵循 Oracle 终身支持策略,其中包括 5 年的主要支持和 3 年的扩展支持。

另外,LTS 支持升级到下一个 LTS 系列,例如8.4.x LTS 到9.7.x LTS,而不支持跳过 LTS 系列。例如,8.4.x LTS 不能跳过9.7.x LTS 直接升级到10.7.x LTS。

  • MySQL Innovation 创新版本

如果你想获得最新的特性,改进和改变。这些版本非常适合在快节奏的开发环境中工作的开发人员和 DBA,这些开发环境具有高水平的自动化测试和现代持续集成技术,可以加快升级周期。例如:8.1–8.3、9.1–9.6 这些都是创新版本,包含一些新特性。

行为:除了创新版本中的新特性外,随着代码重构、移除不推荐的功能以及修改 MySQL 使其行为更符合 SQ L标准,行为也会发生变化。这不会在 LTS 版本中发生。行为更改会产生很大的影响,特别是在处理任何与应用程序相关的内容时,例如SQL语法、新的保留词、查询执行和查询性能。行为更改可能需要更改应用程序,这可能涉及大量迁移工作。我们打算提供必要的工具和配置设置,以使这些转换更容易。

支持:支持创新版本直到下一个创新版本。

支持向量的 MySQL 9.0 已发布,我却看不懂 MySQL 的骚操作了!-3

https://dev.mysql.com/doc/refman/9.0/en/mysql-releases.html

创新版本安装也遵循类似的行为,即创新版本升级到最近的创新系列版本。例如,MySQL 9.0.0 创新版将升级到 MySQL 9.3.0。

支持向量的 MySQL 9.0 已发布,我却看不懂 MySQL 的骚操作了!-4

MySQL 版本生命周期图

主要区别在于,您不能直接在创新系列的不同主要版本之间进行升级,例如 8.3.0 到9.0.0。相反,应该先升级到最近的 LTS 系列,然后再升级到下面的 Innovation 系列。例如,从8.3.0 升级到 8.4.0,再从 8.4.0 升级到 9.0.0,就是有效的升级路径。

支持向量的 MySQL 9.0 已发布,我却看不懂 MySQL 的骚操作了!-5

MySQL 9.0 中的新功能

  • 从 MySQL 9.0.0 开始可以保存 EXPLAIN ANALYZE INTO 的 JSON 输出,语法如下:

EXPLAIN ANALYZE FORMAT=JSON INTO @variable select_stmt

注意:只有当 explain_json_format_version 系统变量设置为 2 时,此特性才可用.

  • 从 MySQL 9.0.0 开始,‘CREATE EVENT’、‘ALTER EVENT’、‘DROP EVENT’ DDL event 可以作为 PREPARE 阶段执行。

  • 从 MySQL 9.0.0 开始,添加两个 Performance Schema 系统变量表。

    • variables_metadata:提供了关于系统变量的一般信息。这些信息包括 MySQL 服务器识别的每个系统变量的名称、作用域、类型、范围(如适用)和描述。该表中的两个列(MIN_VALUE 和 MAX_VALUE)用于替换 variables_info 表中已弃用的列。

    • global_variale_attributes:提供了关于服务器分配给全局系统变量的属性值对的信息。

  • 从 MySQL 9.0.0 开始,“mysql_native_password” 插件已经被删除,如果客户端软件不具备“CLIENT_PLUGIN_AUTH”能力将无法连接服务器。为了向后兼容,mysql_native_password 在客户端仍然可用,以便 MySQL 9.0 客户端程序可以连接到早期版本的 MySQL 服务器。在MySQL 9.0中,MySQL原生身份验证插件已经被转换为必须在运行时加载的插件。

    由于这一变化,以下服务器参数和变量也被删除:
    –mysql-native-password 服务器选项
    –mysql-native-password-proxy-users 服务器选项
    default_authentication_plugin 服务器系统变量

没有系统变量、状态变量或服务器选项,在 MySQL 9.0 中弃用。更多详细内容请访问 MySQL 官网。

没有了,就这。。。。。。挤牙膏了吗?相反五月份发布的 Oracle 23ai 新版本发布了 300 多项新特性,MySQL 就这???“What Is New” 就这些了?真让人吃惊,前面发布的长周期支持版本 8.4.0 也是,除了 8.2 版本的 Router 读写分离的端口外,几乎没有看到有啥特别吸引人的新特性,大失所望,有没有呢?欢迎大佬们来评论区聊聊!

安装 MySQL 9.0 玩玩 Vector 向量数据类型

那就这样吧,没有官方文档说明,只能摸索,这里通过下载 rpm 包来安装,我的环境是 X86 下的 Oracle Linux 8.7,故这里下载 Linux 8 版本的 mysql-9.0.0-1.el8.x86_64.rpm-bundle.tar 安装包,并上传到服务器解压。

支持向量的 MySQL 9.0 已发布,我却看不懂 MySQL 的骚操作了!-6

[root@jiekexu soft]# cd mysql9.0/
[root@jiekexu mysql9.0]# ll
total 993560
-rw-r--r-- 1 root root 1017405440 Jul 2 11:08 mysql-9.0.0-1.el8.x86_64.rpm-bundle.tar
[root@jiekexu mysql9.0]# tar -xvf mysql-9.0.0-1.el8.x86_64.rpm-bundle.tar
mysql-community-client-9.0.0-1.el8.x86_64.rpm
mysql-community-client-debuginfo-9.0.0-1.el8.x86_64.rpm
mysql-community-client-plugins-9.0.0-1.el8.x86_64.rpm
mysql-community-client-plugins-debuginfo-9.0.0-1.el8.x86_64.rpm
mysql-community-common-9.0.0-1.el8.x86_64.rpm
mysql-community-debuginfo-9.0.0-1.el8.x86_64.rpm
mysql-community-debugsource-9.0.0-1.el8.x86_64.rpm
mysql-community-devel-9.0.0-1.el8.x86_64.rpm
mysql-community-icu-data-files-9.0.0-1.el8.x86_64.rpm
mysql-community-libs-9.0.0-1.el8.x86_64.rpm
mysql-community-libs-compat-9.0.0-1.el8.x86_64.rpm
mysql-community-libs-compat-debuginfo-9.0.0-1.el8.x86_64.rpm
mysql-community-libs-debuginfo-9.0.0-1.el8.x86_64.rpm
mysql-community-server-9.0.0-1.el8.x86_64.rpm
mysql-community-server-debug-9.0.0-1.el8.x86_64.rpm
mysql-community-server-debug-debuginfo-9.0.0-1.el8.x86_64.rpm
mysql-community-server-debuginfo-9.0.0-1.el8.x86_64.rpm
mysql-community-test-9.0.0-1.el8.x86_64.rpm
mysql-community-test-debuginfo-9.0.0-1.el8.x86_64.rpm

yum 安装 MySQL 9.0

直接使用 yum mysql-commu*.rpm 安装所有的 rpm 包。

[root@jiekexu mysql9.0]# yum install mysql-commu*.rpm
Last metadata expiration check: 0:53:34 ago on Tue 02 Jul 2024 04:35:39 PM CST.
Dependencies resolved.
=============================================================================================================================================================================================
Package Architecture Version Repository Size
=============================================================================================================================================================================================
Installing:
mysql-community-client x86_64 9.0.0-1.el8 @commandline 15 M
mysql-community-client-debuginfo x86_64 9.0.0-1.el8 @commandline 29 M
mysql-community-client-plugins x86_64 9.0.0-1.el8 @commandline 4.7 M
mysql-community-client-plugins-debuginfo x86_64 9.0.0-1.el8 @commandline 4.7 M
mysql-community-common x86_64 9.0.0-1.el8 @commandline 696 k
mysql-community-debuginfo x86_64 9.0.0-1.el8 @commandline 7.0 M
mysql-community-debugsource x86_64 9.0.0-1.el8 @commandline 21 M
mysql-community-devel x86_64 9.0.0-1.el8 @commandline 8.2 M
mysql-community-icu-data-files x86_64 9.0.0-1.el8 @commandline 2.2 M
mysql-community-libs x86_64 9.0.0-1.el8 @commandline 1.5 M
mysql-community-libs-compat x86_64 9.0.0-1.el8 @commandline 1.5 M
mysql-community-libs-compat-debuginfo x86_64 9.0.0-1.el8 @commandline 2.8 M
mysql-community-libs-debuginfo x86_64 9.0.0-1.el8 @commandline 2.7 M
mysql-community-server x86_64 9.0.0-1.el8 @commandline 61 M
mysql-community-server-debug x86_64 9.0.0-1.el8 @commandline 25 M
mysql-community-server-debug-debuginfo x86_64 9.0.0-1.el8 @commandline 161 M
mysql-community-server-debuginfo x86_64 9.0.0-1.el8 @commandline 244 M
mysql-community-test x86_64 9.0.0-1.el8 @commandline 350 M
mysql-community-test-debuginfo x86_64 9.0.0-1.el8 @commandline 29 M
Installing dependencies:
perl-JSON noarch 2.97.001-2.el8 ol8_AppStream 96 k
perl-Memoize noarch 1.03-421.el8 ol8_AppStream 118 k
perl-Time-HiRes x86_64 4:1.9758-2.el8 ol8_AppStream 61 k

Transaction Summary
=============================================================================================================================================================================================
Install 22 Packages

Total size: 971 M
Installed size: 3.9 G
Is this ok [y/N]: y

.......

Installed:
mysql-community-client-9.0.0-1.el8.x86_64 mysql-community-client-debuginfo-9.0.0-1.el8.x86_64 mysql-community-client-plugins-9.0.0-1.el8.x86_64
mysql-community-client-plugins-debuginfo-9.0.0-1.el8.x86_64 mysql-community-common-9.0.0-1.el8.x86_64 mysql-community-debuginfo-9.0.0-1.el8.x86_64
mysql-community-debugsource-9.0.0-1.el8.x86_64 mysql-community-devel-9.0.0-1.el8.x86_64 mysql-community-icu-data-files-9.0.0-1.el8.x86_64
mysql-community-libs-9.0.0-1.el8.x86_64 mysql-community-libs-compat-9.0.0-1.el8.x86_64 mysql-community-libs-compat-debuginfo-9.0.0-1.el8.x86_64
mysql-community-libs-debuginfo-9.0.0-1.el8.x86_64 mysql-community-server-9.0.0-1.el8.x86_64 mysql-community-server-debug-9.0.0-1.el8.x86_64
mysql-community-server-debug-debuginfo-9.0.0-1.el8.x86_64 mysql-community-server-debuginfo-9.0.0-1.el8.x86_64 mysql-community-test-9.0.0-1.el8.x86_64
mysql-community-test-debuginfo-9.0.0-1.el8.x86_64 perl-JSON-2.97.001-2.el8.noarch perl-Memoize-1.03-421.el8.noarch
perl-Time-HiRes-4:1.9758-2.el8.x86_64

Complete!

支持向量的 MySQL 9.0 已发布,我却看不懂 MySQL 的骚操作了!-7

启动 MySQL 9.0

执行“systemctl start mysqld” 启动并初始化 MySQL9.0。

[root@jiekexu mysql9.0]# cd /var/lib/mysql
[root@jiekexu mysql]# ll
total 0
[root@jiekexu mysql]# systemctl start mysqld
[root@jiekexu mysql]# systemctl status mysqld
? mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2024-07-02 17:37:16 CST; 19s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 1450526 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 1450600 (mysqld)
Status: "Server is operational"
Tasks: 35 (limit: 100127)
Memory: 483.0M
CGroup: /system.slice/mysqld.service
+-1450600 /usr/sbin/mysqld

Jul 02 17:37:08 jiekexu systemd[1]: Starting MySQL Server...
Jul 02 17:37:16 jiekexu systemd[1]: Started MySQL Server.
[root@jiekexu mysql]# pwd
/var/lib/mysql
[root@jiekexu mysql]# ls
auto.cnf ca-key.pem client-key.pem ib_buffer_pool '#innodb_redo' mysql.ibd mysql_upgrade_history public_key.pem sys
binlog.000001 ca.pem '#ib_16384_0.dblwr' ibdata1 '#innodb_temp' mysql.sock performance_schema server-cert.pem undo_001
binlog.index client-cert.pem '#ib_16384_1.dblwr' ibtmp1 mysql mysql.sock.lock private_key.pem server-key.pem undo_002

# --查看 OS 版本
[root@jiekexu mysql]# cat /etc/os-release
NAME="Oracle Linux Server"
VERSION="8.7"

ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="8.7"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Oracle Linux Server 8.7"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:8:7:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://bugzilla.oracle.com/"

ORACLE_BUGZILLA_PRODUCT="Oracle Linux 8"
ORACLE_BUGZILLA_PRODUCT_VERSION=8.7
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=8.7

支持向量的 MySQL 9.0 已发布,我却看不懂 MySQL 的骚操作了!-8

然后我们通过查看 /var/log/mysqld.log 日志找到初始化密码,进行登录并修改 root 密码。

[root@jiekexu mysql]# grep 'temporary password' /var/log/mysqld.log
2024-07-02T09:37:13.723904Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: dH92CaisUO:j

[root@jiekexu mysql]# mysql -uroot -pdH92CaisUO:j
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 9.0.0

Copyright (c) 2000, 2024, Oracle and/or its affiliates.

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.

mysql> select version();
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> \s
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql>
mysql> alter user root@localhost identified by 'MySQL9.0';
Query OK, 0 rows affected (0.05 sec)

mysql> select version();
+-----------+
| version() |
+-----------+
| 9.0.0 |
+-----------+
1 row in set (0.03 sec)

mysql> \s
--------------
mysql Ver 9.0.0 for Linux on x86_64 (MySQL Community Server - GPL)

Connection id: 8
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 9.0.0
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8mb4
Db characterset: utf8mb4
Client characterset: utf8mb4
Conn. characterset: utf8mb4
UNIX socket: /var/lib/mysql/mysql.sock
Binary data as: Hexadecimal
Uptime: 1 hour 21 min 12 sec

Threads: 2 Questions: 10 Slow queries: 0 Opens: 130 Flush tables: 3 Open tables: 46 Queries per second avg: 0.002
--------------
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)

体验 MySQL Vector 向量

首先我们先创建库和表,然后创建带 vector 类型的列和表,通过函数 to_vector 插入向量数据类型,from_vector 查看向量数据,vector_dim 计算向量维度等等。其他好玩的特性不知道官方啥时候能公布?感兴趣的大佬只能去看源码了。看完源码有知道的大佬来评论区聊聊呀!

mysql> create database jiekexu;
Query OK, 1 row affected (0.00 sec)

mysql> use jiekexu;
Database changed
mysql> create table t_vector (id int, c_v vector);
Query OK, 0 rows affected (0.05 sec)

mysql> insert into t_vector(1,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 '1,1)' at line 1
mysql> insert into t_vector values(1,1);
ERROR 6136 (HY000): Value of type 'numeric, size: 8' cannot be converted to 'vector' type.
mysql>
mysql> insert into t_vector values(1,[1,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 '[1,1])' at line 1
mysql>
mysql> insert into t_vector values(1,to_vector([1,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 '[1,1]))' at line 1

mysql> insert into t_vector values(1,to_vector('[1,1]'));
Query OK, 1 row affected (0.00 sec)

mysql> select * from t_vector;
+------+--------------------+
| id | c_v |
+------+--------------------+
| 1 | 0x0000803F0000803F |
+------+--------------------+
1 row in set (0.00 sec)

mysql> insert t_vector select 2,to_vector('[2,2]');
Query OK, 1 row affected (0.00 sec)
Records: 1 Duplicates: 0 Warnings: 0

mysql> select * from t_vector;
+------+--------------------+
| id | c_v |
+------+--------------------+
| 1 | 0x0000803F0000803F |
| 2 | 0x0000004000000040 |
+------+--------------------+
2 rows in set (0.00 sec)
mysql> select id,from_vector(c_v) from t_vector;
+------+---------------------------+
| id | from_vector(c_v) |
+------+---------------------------+
| 1 | [1.00000e+00,1.00000e+00] |
| 2 | [2.00000e+00,2.00000e+00] |
+------+---------------------------+
2 rows in set (0.00 sec)

mysql> select id,vector_dim(c_v) from t_vector;
+------+-----------------+
| id | VECTOR_DIM(c_v) |
+------+-----------------+
| 1 | 2 |
| 2 | 2 |
+------+-----------------+
2 rows in set (0.00 sec)

支持向量的 MySQL 9.0 已发布,我却看不懂 MySQL 的骚操作了!-9

总 结

MySQL 9.0 官方文档中的新特性几乎没有啥可以聊的,但不知为何可以支持 vector 向量数据类型却没有在官方文档中有任何说明,不知道是官方文档还没来得急更新相关信息还是说 9.0 版本只是有这个功能暂未公开说明,这个不得而知,这个骚操作只能等待官方后面看会不会解释了。

参考链接

https://dev.mysql.com/downloads/mysql/
https://mp.weixin.qq.com/s/wFOANEYKLNiy5lC1nXbTVA
https://dev.mysql.com/doc/relnotes/mysql/9.0/en/news-9-0-0.html
https://dev.mysql.com/doc/refman/9.0/en/linux-installation-rpm.html
https://blogs.oracle.com/mysql/post/mysql-july-2024-ga-releases-now-available

全文完,希望可以帮到正在阅读的你,如果觉得有帮助,可以分享给你身边的朋友,同事,你关心谁就分享给谁,一起学习共同进步~~~

❤️ 欢迎关注我的公众号【JiekeXu DBA之路】,一起学习新知识!
——————————————————————————
公众号:JiekeXu DBA之路
墨天轮:https://www.modb.pro/u/4347
CSDN :https://blog.csdn.net/JiekeXu
ITPUB:https://blog.itpub.net/69968215
腾讯云:https://cloud.tencent.com/developer/user/5645107
——————————————————————————

支持向量的 MySQL 9.0 已发布,我却看不懂 MySQL 的骚操作了!-10

相关文章

pt-kill工具的使用
pt-ioprofile工具包的使用
数据库管理-第216期 Oracle的高可用-01(20240703)
DBMS_REPAIR EXAMPLE SCRIPT WITH PARTITION
数据库事务的四大特性: ACID 
使用BBED修复损坏的SYSTEM文件头

发布评论