2. 将下载文件解压到一个文件夹:D:\AZ\
3. 配置环境变量:Path:D:\AZ\mysql-8.0.18-winx64\bin
4. 创建my.ini文件,放在:D:\AZ\mysql-8.0.18-winx64\ 目录下
5. 编辑my.ini文件,我的内容如下,注意保存成ASCII格式:
[mysqld]
bind-address = 0.0.0.0
basedir = D:\AZ\mysql-8.0.18-winx64
datadir = D:\AZ\mysql-8.0.18-winx64\data
port = 3306
max_connections = 200
loose-default-character-set = utf8
explicit_defaults_for_timestamp = true
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
wait_timeout=315360000
interactive-timeout=315360000
[client]
port=3306
default-character-set = utf8
[WinMySQLadmin]
Server = D:\AZ\mysql-8.0.18-winx64\bin
6. 管理员运行cmd命令,进入D:\AZ\mysql-8.0.18-winx64\bin 目录下,运行:mysqld –-initialize
7. 上一步会产生一个 D:\AZ\mysql-8.0.18-winx64\data 文件夹
8. 安装MySQL服务,继续第6步,运行:mysqld install
9. 启动服务:net start mysql
10. 登陆:mysql -u root -p
11. 第10步会提示你输入密码,找到第7步生成的data文件夹,找到后缀.err的文件,搜索password关键字,查看临时密码,输入
12. 修改密码:
set password for 用户名@localhost = password('新密码');
# 如果上面不行,运行下面修改密码的方式
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';
ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';
FLUSH PRIVILEGES; # 刷新权限
13. 退出登陆:exit
14. 停止服务:net stop mysql
15. 卸载服务:
注册表删除:
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\eventlog\Application\MySQL" /f
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Services\eventlog\Application\MySQL" /f # 可能没有
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application\MySQL" /f # 可能没有
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\MySQL" /f # 可能没有
net stop mysql
sc delete mysql
然后删除文件夹