Rocky Linux 9 安装 MySQL 8.*
1、在mysql官方网站下载rpm源安装包:
wget https://dev.mysql.com/get/mysql80-community-release-el9-1.noarch.rpm
2、安装源
dnf install -y mysql80-community-release-el9-1.noarch.rpm
3、安装MySQL
dnf install -y install mysql-community-server
4、启动MySQL并设置服务自启
systemctl start mysqld.service
systemctl enable mysqld.service
systemctl status mysqld.service
看到上图中running字样表示服务启动成功
5、密码设置
查询初始密码
grep "password" /var/log/mysqld.log
mysql -uroot -p
#然后输入刚查出来的初始密码,此处不会有字符回显
修改密码(必做,否则后面很多操作无法进行)
ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码(要满足安全需求)';
#若密码不满足安全需求,会报错:
#Your password does not satisfy the current policy requirements
6、扩展配置(设置root用户远程登录功能)
use mysql; update user set host = '%' where user = 'root'; alter user 'root'@'%' identified with mysql_native_password by '密码(同上面新设置的密码)'; flush privileges;