1.下载YUM库(下载本地在传输到虚拟机)
wget http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
2.安装YUM库
yum -y install mysql57-community-release-el7-10.noarch.rpm
3.安装数据库
yum -y install mysql-community-server
4.完成安装,重启mysql
systemctl restart mysqld
此时MySQL已经开始正常运行,不过要想进入MySQL还得先找出此时root用户的密码,通过如下命令可以在日志文件中找出密码:
grep “password” /var/log/mysqld.log
[root@hadoop8 ~]# grep “password” /var/log/mysqld.log
2018-10-13T08:33:27.994868Z 1 [Note] A temporary password is generated for root@localhost: yj0v.0w*ywPk
5.复制粘贴上边的密码进入数据库
mysql -uroot -p
输入初始密码,此时不能做任何事情,因为MySQL默认必须修改密码之后才能操作数据库修改密码命令:
ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘123456’;
Your password does not satisfy the current policy requirements
6.解决报错
修改密码策
因为当前的密码太复杂不方便后期做实验,所以使用命令修改密码策略两种方式:
mysql> set global validate_password_policy=0;
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_policy=LOW;
mysql> set global validate_password_policy=LOW;
Query OK, 0 rows affected (0.00 sec)
注:密码策略分四种
1、OFF(关闭) 2、LOW(低) 3、MEDIUM(中) 4、STRONG(强)
上边改完策略之后我们在改长度
mysql> SET GLOBAL validate_password_length=6;
mysql> SET GLOBAL validate_password_length=6;
Query OK, 0 rows affected (0.00 sec)
注:执行完初始化命令后需要输入数据库root用户密码