下载mysql 5.7.22,网址 https://dev.mysql.com/downloads/

解压文件,发现根目录下没有data目录 使用CMD(管理员运行)进入bin 目录:

cd C:\mysql-5.7.22-winx64\bin   执行

mysqld --initialize-insecure --user=mysql

执行完命令发现根目录多了个data 的文件夹

配置my.ini 文件,文件内容如下:

[client]

port=3306

default-character-set=utf8

[mysqld]

#设置mysql的安装目录

basedir=C:\mysql-5.7.22-winx64

#设置mysql的数据目录

datadir=C:\mysql-5.7.22-winx64\data

character_set_server=utf8

sql_mode=NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER

#开启查询缓存

explicit_defaults_for_timestamp=true

执行命令:

mysqld install MYSQL57 --defaults-file="C:\mysql-5.7.22-winx64\my.ini"

启动mysql 服务,(默认密码为空)登录进去

启动命令net start mysql  停止命令net stop mysql

update mysql.user set authentication_string=password('newpwd'),password_expired='N' where user='root';

修改密码并修改过时策略(字段名和mysql 5.6略有不同,5.6的:update user set password = password('newpwd'),password_expired='N' where user = 'root';)

-- 开启远程连接权限 grant all on . to root@'%' identified by 'newpwd' with grant option;

flush privileges;

然后重启mysql 服务就配置完成了