通过yum安装,先查看系统版本
$> uname -a
Linux mysql 3.10.0-1160.81.1.el7.x86_64 #1 SMP Fri Dec 16 17:29:43 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
得出我的版本是el7,随后在MySQL Yum Repository中下载对应版本,然后安装
$> rpm -ivh mysql80-community-release-el7-7.noarch.rpm
$> yum update
$> yum install mysql-server
查看一下运行状态
systemctl status mysqld
在安装日志中查看默认生成的密码
$> sudo grep 'temporary password' /var/log/mysqld.log
登陆然后修改默认生成的密码
$> mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';