写个博客记录一下,省得下次换设备换系统还要到处翻教程,直接匹配自己常用的8.0.13版本
1.MySQL包解压到某个路径
2.将bin的路径加到系统环境变量Path下
3.在安装根目录下新建my.ini配置文件,并用编辑器写入如下数据
[mysqld]
[client]
port = 3306
default-character-set = UTF8MB4 [mysqld]
port = 3306
character-set-server = UTF8MB4 basedir=D:\opt\apps\mysql-8.0.13-winx64
datadir=D:\opt\apps\mysql-8.0.13-winx64\datagroup_concat_max_len=20000[WinMySQLAdmin]
D:\opt\apps\mysql-8.0.13-winx64\bin\mysqld.exe
4.运行指令安装
用管理员身份运行命令行,进入到MySQL下的bin目录,执行指令:
mysqld --initialize --console
执行完后记录下这里获取的临时密码
C:\Users\Administrator>cd C:\Program Files\MySQL\binC:\Program Files\MySQL\bin>mysqld --initialize --console
2022-04-28T15:57:17.087519Z 0 [System] [MY-013169] [Server] C:\Program Files\MySQL\bin\mysqld.exe (mysqld 8.0.11) initializing of server in progress as process 4984
2022-04-28T15:57:24.859249Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: rI5rvf5x5G,E
2022-04-28T15:57:27.106660Z 0 [System] [MY-013170] [Server] C:\Program Files\MySQL\bin\mysqld.exe (mysqld 8.0.11) initializing of server has completed
然后在bin目录下执行命令安装MySQL
mysqld --install
启动MySQL服务
net start mysql
紧接着使用之前的临时密码登录进去(敲进去,别粘贴)
mysql -u root -p
然后执行更改初始密码命令(我这个版本使用123456这种弱密码是可以通过的,有的版本还有密码强度规定,有点麻烦)
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
然后输入exit退出并用新密码登进去试试