1.安装包下载:
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
2.安装源安装:
yum -y localinstall mysql57-community-release-el7-11.noarch.rpm
3.在线安装mysql
yum -y install mysql-community-server
4.启动服务
systemctl start mysqld
5.查看默认密码并修改密码
mysql安装完成之后,会在/var/log/mysqld.log文件中给root生成了一个临时的默认密码。
cat /var/log/mysqld.log
修改root密码:
默认会有密码规则限制,太简单会报错,可关闭规则校验或者设置复杂一点
默认新密码必须包含大写字母、小写字母、数字、标点符号,且密码长度至少为 8
ALTER USER 'root'@'localhost' IDENTIFIED BY 'spj+123@Pass';
6.设置远程登录
选择mysql数据库 use mysql; 设置root用户远程登录 Grant all on *.* to 'root'@'%' identified by 'spj+123@Pass' with grant option; 刷新权限 flush privileges; 查看哪些用户和host可以访问,%代表任意ip地址 select user,host from user;
7.设置开机自启
systemctl enable mysqld systemctl daemon-reload