step one
Unzip the package in your local directory and copy the path like D:\mysql-8.0.11-winx64\bin
Add environment variable : add it into System Variables Path
step two
Create a file my.ini and put it into the folder D:\mysql-8.0.11-winx64\bin
Note: the content about path depend on you own directory
my.ini
[client]
port=3306
default-character-set=utf8
[mysqld]
# 设置为自己MYSQL的安装目录
basedir=D:\mysql-8.0.11-winx64
# 设置为MYSQL的数据目录
datadir=D:\mysql-8.0.11-winx64\data
port=3306
character_set_server=utf8
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
[WinMySQLAdmin]
%MYSQL_HOME%\bin\mysqld.exe
#开启查询缓存
#explicit_defaults_for_timestamp=true
#skip-grant-tables
step three
Run cmd as the administrator,and cd into path like D:\mysql-8.0.11-winx64\bin
//mysql安装
mysqld -install
//执行结果为 Service Successfully installed
//初始化mysql数据,并创建一个具有空密码的root用户
mysqld --initialize-insecure
//注意:最后的参数 --user=mysql 在 windows 也可以不用添加,但在 unix 等系统下好像很重要。执行命令后,等一会后,系统会自动生成相应的 data 目录,并自动创建好空密码的 root 用户。此时表示初始化成功。
//开启服务
net start mysql
//执行结果为The MySQL sevice is starting...
//The MySQL service was started successfully.
//原密码为空直接回车即可
mysqladmin -u root -p password 新密码
Enter password: //旧密码回车即可
New Password://新密码
Confirm New password://新密码
Step four
Almost done.let's test it right now.
net stop mysql
net start mysql
mysql -u root -p
Enter password: //新密码
Now you are in ;-)