1、下载mysql官方yum repository

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

Linux服务器安装Mysql - 图1

2、安装yum repository

安装
yum -y install mysql57-community-release-el7-10.noarch.rpm

Linux服务器安装Mysql - 图2
Linux服务器安装Mysql - 图3

3、安装mysql服务

rpm —import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

yum -y install mysql-community-server

Linux服务器安装Mysql - 图4Linux服务器安装Mysql - 图5

4、启动mysql

systemctl start mysqld.service

Linux服务器安装Mysql - 图6

5、获取mysql随机密码

grep “password” /var/log/mysqld.log

Linux服务器安装Mysql - 图7

6、连接数据库

mysql -u root -p

Linux服务器安装Mysql - 图8

  • 右键复制并粘贴的随机密码Linux服务器安装Mysql - 图9Linux服务器安装Mysql - 图10

    7、修改mysql密码规则

    set global validate_password_policy=0;
    set global validate_password_length=1;

Linux服务器安装Mysql - 图11

8、修改mysql密码

ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘fanmao888’;

Linux服务器安装Mysql - 图12Linux服务器安装Mysql - 图13

9、允许远程用户连接

grant all privileges on . to ‘root’@’%’ identified by ‘fanmao888’ with grant option;

flush privileges;

Linux服务器安装Mysql - 图14
Linux服务器安装Mysql - 图15

  • 断开mysql连接

exit;