CentOS7带有MariaDB而不是MySQL,如果要安装MySQL,首先添加mysql社区repo,版本参考官方地址
https://dev.mysql.com/downloads/repo/yum/
执行命令:

[root@localhost ~]# sudo rpm -Uvh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

然后安装Mysql,这里版本是5.7.20

[root@localhost ~]# yum install mysql-server 

启动服务

[root@localhost ~]# systemctl start mysqld.service

MySQL5.7 安装成功,为了加强安全性,会自动为root用户生成了一个随机密码

grep "password" /var/log/mysqld.log

随机密码

2017-08-09T04:20:43.628747Z 1 [Note] A temporary password is generated for root@localhost: HcchE4-y*vV6

首次登录提示

You must reset your password using ALTER USER statement before executing this statement.

大概意思就是让你换个密码

修改三步曲

1: SET PASSWORD = PASSWORD('123456');

2: ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;

3: flush privileges;

第一步又有一个提示

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

密码太简单了,再换

SET PASSWORD = PASSWORD('Mokun.123');

搞定,如果你想用简单密码需要修改两个全局配置,请自行搜索实践

本地账号没有问题后,在研发环境要添加远程访问账号,账号密码不变再加个

grant all privileges on *.* to 'root'@'%'identified by 'Mokun.123' with grant option;

flush privileges;

转载请注明原地址: http://blog.noark.xyz/article/2017/8/10/mysql5.7安装小记/