1. 解压并配置
新建 my.ini 配置文件,配置内容入下:
1 [mysqld] 2 basedir=D:\devSoft\mysql-8.0.21-winx64 3 datadir=D:\devSoft\mysql-8.0.21-winx64\data 4 5 default-character-set=utf8 6 7 bind-address=0.0.0.0
2. 初始化
1 cd %mysql_home%in 2 mysqld --initialize --console 3 4 记住密码: 5 这里找不到密码,猜测默认root用户无密码! 6 7 D:devSoftmysql-8.0.21-winx64in>mysqld --initialize --console 8 2020-10-27T06:33:38.100291Z 0 [System] [MY-013169] [Server] D:devSoftmysql-8.0.21-winx64inmysqld.exe (mysqld 8.0.21) initializing of server in progress as process 275136 9 2020-10-27T06:33:38.611819Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 10 2020-10-27T06:33:49.304907Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 11 2020-10-27T06:34:17.576783Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: zgZA(5NtL_<q 12 13 D:devSoftmysql-8.0.21-winx64in> 14 15 注意: 要把原本已有的 MySQL 环境变量 删掉,不然初始化操作会出问题!
3. 注册为Windows服务
注册服务
mysqld --install mysql8
移除服务:
SC delete mysql8
4. 启动mysql服务
net start mysql8
5. 登录
cd %mysql_home%in
mysql -uroot -pzgZA(5NtL_<q
6. 重置root用户密码
方式一:
ALTER USER "root"@"localhost" IDENTIFIED BY "root"
方式二:(这个方式尝试没成功)
set password for root@localhost=password('666');
7. 允许远程访问
use mysql
update user set host='%' where user='root';
mysql> select host,user from user;
1 +-----------+------------------+ 2 | host | user | 3 +-----------+------------------+ 4 | % | root | 5 | localhost | mysql.infoschema | 6 | localhost | mysql.session | 7 | localhost | mysql.sys | 8 +-----------+------------------+ 9 4 rows in set (0.00 sec)
8.常见问题
问题: VCRUNTime140_1.dll 找不到
解决:从微软官方下载VCRUNTime140_1.dll,放到 C:WindowsSystem32 目录下