1、安装MySQL5.7
yum install -y -q https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm
yum -y install yum-utils
yum-config-manager --disable mysql80-community
yum-config-manager --enable mysql57-community
yum install -y mysql-community-server
2、启动服务
sudo systemctl enable mysqld
sudo systemctl start mysqld
3、查询初始密码
grep 'temporary password' /var/log/mysqld.log
4、使用初始密码登录
mysql -uroot -p
Enter password: #输入初始密码
注意:
如果输入完密码提示
ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password:yes)
则
1、停止mysql服务
systemctl stop mysqld.service
2、修改配置文件无密码登录
vim /etc/my.cnf
在最后加上
skip-grant-tables
保存
3、启动mysql
systemctl start mysqld.service
4、登录mysql
mysql -u root
5、修改密码,mysql5.7用此语法
use mysql;
update mysql.user set authentication_string=password('123456') where user='root' ;
flush privileges;
6、回到第二部把刚加的那句删掉
保存,重启mysql就可以了
——————————————————————————————————————————————————
如果没有提示则继续往下走
5、更改密码复杂度策略,可以设置简单密码
mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=1;
6、允许远程访问
mysql> grant all privileges on *.* to 'root'@'%' identified by 'password' with grant option;
mysql> flush privileges;