1、下载yum源
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
2、安装
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
3、进到/etc/yum.repos.d目录,执行yum命令
cd /etc/yum.repos.d
yum install mysql-server
4、启动
systemctl start mysqld
#开机启动
systemctl enable mysqld
5、首次连接mysql需要获取临时密码,然后进入修改密码
grep 'temporary password' /var/log/mysqld.log
#修改密码验证级别和密码长度
set global validate_password_policy=LOW;
set global validate_password_length=6;
#设置密码
set password=password('password');
6、设置远程连接
use mysql;
update user set Host='%' where User='root';
flush privileges;
8、阿里云控制台开放3306端口,远程可访问
注:
配置文件位置: /etc/my.cnf