MySQL 8.4.0 LTS 已经发布 ,作为发版模型变更后的第一个长期支持版本,注定要承担未来生产环境的重任,那么这个版本都有哪些新特性、变更,接下来少安将带大家一起来 get 新知识点。
环境准备
本文涉及到源码编译,先说明下环境信息,操作系统为 Rocky 9。
Tips:
CentOS 7 即将 EOL,建议直接升级到 RHEL 9,如果考虑到费用或者国产化操作系统替代的问题,可以选择 Oracle Linux 9 或者 Rocky Linux 9。
具体信息如下:
1 2 3 4 5 6 7 8 9 10 11 12
[mysql@shawnyan ~]$ cat /etc/redhat-release Rocky Linux release 9.3 (Blue Onyx) [mysql@shawnyan ~]$ gcc --version gcc (GCC) 11.4.1 20230605 (Red Hat 11.4.1-2) Copyright (C) 2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[mysql@shawnyan ~]$ cmake --version cmake version 3.20.2
CMake suite maintained and supported by Kitware (kitware.com/cmake).
编译要求
如果你需要编译 MySQL 8.4.0 源码,那么 CMake 的最小版本需要升级到 3.14.6,之前是 3.5.1。
当然,我这里使用的是 3.20.2,符合最低要求。
编译选项
MySQL 源码编译不在需要添加 BOOST 相关选项:WITH_BOOST, DOWNLOAD_BOOST, DOWNLOAD_BOOST_TIMEOUT
tar zxf mysql-8.4.0.tar.gz cd mysql-8.4.0 mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=Debug -DEXTRA_VERSION="-ShawnYan"
输出:
1 2 3 4 5 6 7 8 9 10
[mysql@shawnyan build]$ cmake .. -DCMAKE_BUILD_TYPE=Debug -DEXTRA_VERSION="-ShawnYan" -- Running cmake version 3.20.2 -- Found Git: /usr/bin/git (found version "2.39.3") -- This is .el9. as found from 'rpm -qf /' -- Looking for a devtoolset compiler -- Using /opt/rh/gcc-toolset-12/root/usr/bin/gcc -- Using /opt/rh/gcc-toolset-12/root/usr/bin/g++ -- CMAKE_MODULE_PATH is /data/mysql-8.4.0/cmake -- MySQL 8.4.0-ShawnYan ...
配置完成后,执行编译,开始进入漫长的等待。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
[mysql@shawnyan build]$ make [ 0%] Built target absl_log_severity ... [ 9%] Built target mysql_serialization [ 9%] Built target mysql_gtid [ 9%] Built target all_sys_schema [ 9%] Built target comp_sql ... [ 91%] Built target sql_dd [ 92%] Built target rpl_replica [ 93%] Built target sql_gis [ 94%] Built target binlog [ 94%] Built target rpl [ 97%] Built target innobase [ 97%] Built target mysqld [100%] Built target merge_large_tests-t
编译完成,生成的文件约 17G,需要注意磁盘空间,不然编译还没结束磁盘先满了。
1 2
[mysql@shawnyan mysql-8.4.0]$ du -sh build/ 17G build/
直接启动数据库。
1
./bin/mysqld --datadir=./data
可以看到数据库服务已经顺利启动
1 2 3 4 5 6 7 8 9
[mysql@shawnyan build]$ ./bin/mysqld --datadir=./data 2024-05-14T06:01:15.883098Z 0 [System] [MY-015015] [Server] MySQL Server - start. 2024-05-14T06:01:16.148917Z 0 [System] [MY-010116] [Server] /data/mysql-8.4.0/build/runtime_output_directory/mysqld (mysqld 8.4.0-ShawnYan-debug) starting as process 55817 2024-05-14T06:01:16.172236Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2024-05-14T06:01:17.006479Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2024-05-14T06:01:19.026567Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. 2024-05-14T06:01:19.026626Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel. 2024-05-14T06:01:19.293313Z 0 [System] [MY-010931] [Server] /data/mysql-8.4.0/build/runtime_output_directory/mysqld: ready for connections. Version: '8.4.0-ShawnYan-debug' socket: '/tmp/mysql.sock' port: 3306 Source distribution. 2024-05-14T06:01:19.563373Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /tmp/mysqlx.sock
[mysql@shawnyan build]$ ./bin/mysql -uroot Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 8.4.0-ShawnYan-debug Source distribution
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.
(root@localhost) [(none)] 14:05:17> select version(); +----------------------+ | version() | +----------------------+ | 8.4.0-ShawnYan-debug | +----------------------+ 1 row in set (0.00 sec)
2024-05-14T06:14:59.927757Z 9 [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'
Tips:
建议尽快替换为 caching_sha2_password 认证插件。
从 MySQL 8.0.14 引入的双密码策略,并不支持两种认证插件混用。
总结
本章节我们介绍了编译 MySQL 8.4.0 LTS 源码需要注意几点变更,以及连接数据库时认证插件发生的变化。