CentOS Stream 9 安装 MySQL 8
在 CentOS Stream 9 上装 MySQL 8,从添加软件源到修改初始密码和设置开机启动。
文章目录
1、添加 MySQL 软件源
wget https://repo.mysql.com//mysql80-community-release-el9-1.noarch.rpm
sudo dnf install mysql80-community-release-el9-1.noarch.rpm
2、安装 MySQL 8.0
sudo dnf install mysql-community-server
这里原来放的是本机截图,旧仓库里没有这张图。找到后再补。
3、启动 MySQL 服务
sudo systemctl start mysqld
4、MySQL 初始安全设置
grep 'A temporary password is generated' /var/log/mysqld.log | tail -1
先找到安装时生成的临时密码,下一步要用它登录。
5、用临时密码登录并调整密码等级
先调整密码等级,否则改不了密码。
示例用 CHANGE_ME_STRONG_PASSWORD 占位,运行前换成自己的密码。
mysql -uroot -p
输入临时密码
alter user 'root'@'localhost' identified by 'CHANGE_ME_STRONG_PASSWORD';
更改后修改等级
SHOW VARIABLES LIKE 'validate_password%';
SET GLOBAL validate_password.length = 6;
SET GLOBAL validate_password.number_count = 0;
SET GLOBAL validate_password.policy=LOW;
alter user 'root'@'localhost' identified by 'CHANGE_ME_STRONG_PASSWORD';
6、查看所有用户密码并允许远程登录
show databases;
use mysql;
select host,user,plugin,authentication_string from user;
create user root@'%'' identified with mysql_native_password by '95uoh16j';
grant all on *.* to root@'%' with grant option;
#删除非 host 为%的用户
delete from user where host != '%';
#必须执行,否则不生效!!!
flush privileges;
#注:mysql 8.0远程连接,在参数文件的[mysqld]下添加:/etc/my.cnf
default_authentication_plugin=mysql_native_password
7、设置 MySQL 开机启动
sudo systemctl enable mysqld
评论
暂时没有评论。