一、下载并安装MySQL官方的 Yum Repository
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
## 使用上面的命令就直接下载了安装用的Yum Repository,大概25KB的样子,然后就可以直接yum安装了。
yum -y install mysql57-community-release-el7-8.noarch.rpm
yum repolist enabled | grep "mysql.*-community.*"
二、## 安装
yum install mysql-community-server
三、## 启动mysql
systemctl start mysqld
四、## 开机自启
systemctl enable mysqld
systemctl daemon-reload
## 因为安装了Yum Repository,以后每次yum操作都会自动更新,需要把这个卸载掉:
yum -y remove mysql57-community-release-el7-8.noarch
五、## 获取初始密码
grep 'temporary password' /var/log/mysqld.log
##修改root密码
#密码强度设为最低等级0
#密码允许最小长度为1
set global validate_password_policy=0;
set global validate_password_length=1;
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
SHOW VARIABLES LIKE 'validate_password%';
六、## 授权root远程登录
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' ;
七、## 授权其他账号远程登录(同时也是创建一个账号)
CREATE USER 'admin'@'%' IDENTIFIED BY 'admin';
GRANT ALL ON *.* TO 'admin'@'%';
flush privileges ;
八、##新建数据库
CREATE DATABASE IF NOT EXISTS `test` DEFAULT CHARSET utf8 COLLATE utf8_unicode_ci;