MySQL 8.2.0部署安装验证

发布时间 2023-12-16 19:59:14作者: 济南小老虎

MySQL 8.2.0部署安装验证


背景

昨天捯饬了半天Oracle23c Free版本发现自己白忙活了.
然后想着继续看一下 MySQL8.2.
看看会不会又继续白忙活

下载与安装

https://cdn.mysql.com//Downloads/MySQL-8.2/mysql-8.2.0-1.el8.x86_64.rpm-bundle.tar

计划是下载 tar包, 这样比较简单快速.

注意 mysql的tar包 最好在一个特定目录下解压缩,因为他没有上一层的目录

解压缩后 yum localinstall *.rpm 就可以连带着依赖安装上所有的需要的内容. 

修改配置

与之前版本一样
目录是 /etc/my.cnf
可以修改为如下目录
需要注意, 我这个仅是自己的测试:

[mysqld]
datadir=/mysql/data
max_allowed_packet = 1G
innodb_log_file_size = 512M
innodb_log_buffer_size = 512M
innodb_file_per_table = 1
innodb_buffer_pool_size=8G
innodb_flush_log_at_trx_commit=0
max_connections=2000
lower-case-table-names=1
innodb_strict_mode = 0
character_set_server=utf8
secure_file_priv = 
default-time-zone='+08:00'
binlog_expire_logs_seconds = 7200
transaction-isolation = READ-COMMITTED
default_authentication_plugin=mysql_native_password
#skip-grant-tables
[mysql]
prompt="\\u@\\h : \\d \\r:\\m:\\s>"
default-character-set=utf8

数据库初始化

mkdir -p  /mysql/data
chown mysql:mysql /mysql/ -R

mysqld --initialize-insecure

需要注意 我这样初始化有几个问题:
'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
这个参数已经快没有了. 

--character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
utf8mb4的故事人尽皆知, 就不再说了.. 没办法

'mysql_native_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead
密码的策略也需要改.

修改密码

root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
所以理论上 root 在本地可以直接登录

注意需要先启动数据库
chown mysql:mysql /mysql/ -R
systemctl restart mysqld

mysql -uroot  -h127.0.0.1

创建用户和修改密码:
create user root@'%' identified by 'xxxxx';
alter user root@localhost identified by 'xxxxx';

查看用户以及密码验证信息
select user,host,plugin from mysql.user ;

设置开机启动与重启等

systemctl enable --now mysqld
systemctl restart mysqld 

一个变化

MySQL8.2 相比 MySQL8.0 有了一些变化
而且保留字和关键字也有了扩张
会导致之前不报错的SQL,现在报错了. 

这里存在一个比较坑的问题
比如之前产品里面有 parallel的关键字, 现在就会报错如下:
SQLSyntaxErrorException: 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 'PARALLEL bit NULL)' at line 10

查看官方资料:
https://dev.mysql.com/doc/refman/8.0/en/keywords.html#keywords-8-0-detailed-P
https://dev.mysql.com/doc/refman/8.2/en/keywords.html#keywords-8-2-detailed-P

发现两个版本里面 8.2 的确是多了 parallel 一个关键字

产品兼容性路远坑多, 还是需要继续关注.