windows 10 安装 mysql 8.0.15

内容纲要

下载

https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.15-winx64.zip

解压缩

将 mysql 解压缩到 C:\dev\mysql-8.0.15-winx64

安装和启动

zip 包没有安装程序,我想当然的执行 bin 下的 mysqld,当然是不成功,后在网上找了教程才算搞定

失败的尝试

进入 bin 目录执行 mysqld

C:\dev\mysql-8.0.15-winx64\bin
λ mysqld
2021-03-25T03:06:02.422737Z 0 [System] [MY-010116] [Server] C:\dev\mysql-8.0.15-winx64\bin\mysqld.exe (mysqld 8.0.15) starting as process 10480
2021-03-25T03:06:02.425841Z 0 [Warning] [MY-010091] [Server] Can't create test file C:\dev\mysql-8.0.15-winx64\data\DELL-ZHYAN.lower-test
2021-03-25T03:06:02.425926Z 0 [Warning] [MY-010091] [Server] Can't create test file C:\dev\mysql-8.0.15-winx64\data\DELL-ZHYAN.lower-test
2021-03-25T03:06:02.426106Z 0 [ERROR] [MY-013276] [Server] Failed to set datadir to 'C:\dev\mysql-8.0.15-winx64\data\' (OS errno: 2 - No such file or directory)
2021-03-25T03:06:02.503600Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-03-25T03:06:02.503757Z 0 [System] [MY-010910] [Server] C:\dev\mysql-8.0.15-winx64\bin\mysqld.exe: Shutdown complete (mysqld 8.0.15)  MySQL Community Server - GPL.

貌似没有 data 目录,那么建一个

C:\dev\mysql-8.0.15-winx64\bin
λ cd ..
C:\dev\mysql-8.0.15-winx64
λ mkdir data
C:\dev\mysql-8.0.15-winx64
λ bin\mysqld

没有输出任何信息,这是启动了吗?执行 mysql 试下

C:\dev\mysql-8.0.15-winx64
λ bin\mysql
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

查了下资料,要先安装?

C:\dev\mysql-8.0.15-winx64\bin
λ bin\mysqld --install
Install/Remove of the Service Denied!

怎么不让安装呢?是不是要用管理员权限,重新用管理权权限打开 cmd 试下

C:\dev\mysql-8.0.15-winx64\bin
λ mysqld --install
Service successfully installed.

还真是,接下来启动

C:\dev\mysql-8.0.15-winx64\bin
λ net start mysql
MySQL 服务正在启动 .
MySQL 服务无法启动。

服务没有报告任何错误。

请键入 NET HELPMSG 3534 以获得更多的帮助。

还是不行呢,找了个教程,试下

C:\dev\mysql-8.0.15-winx64\bin
λ mysqld --initialize-insecure

C:\dev\mysql-8.0.15-winx64\bin
λ net start mysql
MySQL 服务正在启动 .
MySQL 服务无法启动。

服务没有报告任何错误。

请键入 NET HELPMSG 3534 以获得更多的帮助。

C:\dev\mysql-8.0.15-winx64\bin
λ  NET HELPMSG 3534

服务没有报告任何错误。

这个教程也不行

正确的安装和启动教程

C:\dev\mysql-8.0.15-winx64\bin
λ mysqld --initialize --console
2021-03-25T03:27:45.483110Z 0 [System] [MY-013169] [Server] C:\dev\mysql-8.0.15-winx64\bin\mysqld.exe (mysqld 8.0.15) initializing of server in progress as process 8300
2021-03-25T03:27:45.485157Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2021-03-25T03:27:45.485173Z 0 [ERROR] [MY-013236] [Server] Newly created data directory C:\dev\mysql-8.0.15-winx64\data\ is unusable. You can safely remove it.
2021-03-25T03:27:45.527015Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-03-25T03:27:45.527154Z 0 [System] [MY-010910] [Server] C:\dev\mysql-8.0.15-winx64\bin\mysqld.exe: Shutdown complete (mysqld 8.0.15)  MySQL Community Server - GPL.

不成功,看提示是 data 目录下有文件,删掉试下

C:\dev\mysql-8.0.15-winx64\bin
λ dir ..\data
 驱动器 C 中的卷没有标签。
 卷的序列号是 4049-54F3

 C:\dev\mysql-8.0.15-winx64\data 的目录

2021/03/25  11:21    <DIR>          .
2021/03/25  11:21    <DIR>          ..
2021/03/25  11:13                 0 binlog.index
2021/03/25  11:21             3,003 DELL-ZHYAN.err
               2 个文件          3,003 字节
               2 个目录 315,364,007,936 可用字节

C:\dev\mysql-8.0.15-winx64\bin
λ del ..\data\*
C:\dev\mysql-8.0.15-winx64\data\*, 是否确认(Y/N)? y

C:\dev\mysql-8.0.15-winx64\bin
λ mysqld --initialize --console
2021-03-25T03:29:16.595159Z 0 [System] [MY-013169] [Server] C:\dev\mysql-8.0.15-winx64\bin\mysqld.exe (mysqld 8.0.15) initializing of server in progress as process 14860
2021-03-25T03:29:21.354623Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: z#2e)AqB%(zh
2021-03-25T03:29:22.873158Z 0 [System] [MY-013170] [Server] C:\dev\mysql-8.0.15-winx64\bin\mysqld.exe (mysqld 8.0.15) initializing of server has completed

注意,安装程序创建了默认用户 root@localhost,并设置了临时密码,后面登入 mysql 要用到这个密码。继续安装

C:\dev\mysql-8.0.15-winx64\bin
λ mysqld --install
The service already exists!
The current server installed: C:\dev\mysql-8.0.15-winx64\bin\mysqld MySQL

因为之前执行过安装,提示服务已存在,先删除 MySQL 服务

C:\dev\mysql-8.0.15-winx64\bin
λ sc delete mysql
[SC] DeleteService 成功

C:\dev\mysql-8.0.15-winx64\bin
λ mysqld --install
Service successfully installed.

安装成功,启动 mysql

C:\dev\mysql-8.0.15-winx64\bin
λ net start mysql
MySQL 服务正在启动 ..
MySQL 服务已经启动成功。

连接上去试下

C:\dev\mysql-8.0.15-winx64\bin
λ mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.15

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

ok,搞定

参考教程

windows 10 安装 mysql 8.0.15

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

Scroll to top
粤ICP备2020114259号 粤公网安备44030402004258