一、 软件下载
![](http://upload-images.jianshu.io/upload_images/8491281-ff7e1c314665893f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000/format/webp)
5.7 32位https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.19-win32.zip
5.7 64位https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.19-winx64.zip
本次教程采用的是64位版本,诸君可根据自己电脑系统和个人喜好酌情处理。
二、 操作步骤
1.下载后得到zip压缩包
![](http://upload-images.jianshu.io/upload_images/8491281-959dfcd660f70287.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/255/format/webp)
2.解压到自己想要安装到的目录,本人解压到的是D:\Program Files(考虑到解压后文件名很长所以我从命名了)
![](http://upload-images.jianshu.io/upload_images/8491281-8764db4c47bae6b1.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/515/format/webp)
3.添加环境变量
我的电脑->属性->高级->环境变量
选择PATH,在其后面添加: 你的mysql 安装文件下面的bin文件夹
(如: D:\Program Files\mysql-5.7\bin )
![](http://upload-images.jianshu.io/upload_images/8491281-b85919ebbb8beed5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/772/format/webp)
(注意不要删除其他的东西)
4.新建 my.ini 文件
![](http://upload-images.jianshu.io/upload_images/8491281-6a4c506e19b25476.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/766/format/webp)
5.编辑my.ini文件
[mysqld]
basedir=D:\Program Files\mysql-5.7\
datadir=D:\Program Files\mysql-5.7\data\
port=3306
skip-grant-tables
#basedir表示mysql安装路径
#datadir表示mysql数据文件存储路径
#port表示mysql端口
#skip-grant-tables表示忽略密码
![](http://upload-images.jianshu.io/upload_images/8491281-2d270c67a3c5fbbb.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/544/format/webp)
6.启动管理员模式下的CMD,并将路径切换至mysql下的bin目录,然后输入
mysqld –install 就行mysql
![](http://upload-images.jianshu.io/upload_images/8491281-f06502f528f5eb1b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/541/format/webp)
7.输入 net start mysql 启动mysql服务
![](http://upload-images.jianshu.io/upload_images/8491281-3a7f36defe505ea2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/505/format/webp)
8.再输入 mysqld --initialize-insecure --user=mysql; 初始化数据文件
![](http://upload-images.jianshu.io/upload_images/8491281-cd61d00da83eed5a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/743/format/webp)
9.然后再次启动mysql 然后用命令 mysql –u root –p 进入mysql管理界面(密码可为空)
![](http://upload-images.jianshu.io/upload_images/8491281-502f436ab42c8a41.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/631/format/webp)
10.进入界面后更改root密码
update mysql.user set authentication_string=password('123456789') where user='root' and Host = 'localhost';
123456789为我的新密码 ,此处密码由您决定
最后输入flush privileges 刷新权限
![](http://upload-images.jianshu.io/upload_images/8491281-1089e95eefbad735.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000/format/webp)
11.修改 my.ini文件删除最后一句skip-grant-tables
![](http://upload-images.jianshu.io/upload_images/8491281-9c18ffffc603d4bb.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/502/format/webp)
12.重启mysql即可正常使用
![](http://upload-images.jianshu.io/upload_images/8491281-d3db65d4c5c2bab2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/526/format/webp)