mysql官网下载地址:https://dev.mysql.com/downloads/mysql/
新版安装包解压后,没有网上教程里面提到的data文件夹和my-default.ini,如下图所示
2.在下面目录下创建my.ini,内容如下:
character_set_server=utf8 #这里网上很多是default-character-set=utf8 ,容易出错
port = 3306
basedir=D:\Java\mysql-5.7.24-winx64
datadir=D:\MySQL\MySQL Server 5.7.23\data 在这里不需要自己去创建一个空的data文件夹
max_connections=200
character-set-server=utf8
default-storage-engine=INNODB
可以直接复制粘贴,主要修改下basedir后的路径,注意路径中为\而非\
3.进入dos的命令行,用administrator进入
a.进入MySQL的bin目录,输入mysqld –install可以安装MySQL
D:\Java\mysql-5.7.35-winx64\bin>mysqld -install
Service successfully installed.
或之前已安装过Mysql卸载不干净
D:\Java\mysql-5.7.35-winx64\bin>mysqld -install
The service already exists!
查看是否存在
D:\Java\mysql-5.7.35-winx64\bin>sc query mysql
SERVICE_NAME: mysql
TYPE : 10 WIN32_OWN_PROCESS
STATE : 1 STOPPED
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
确认之前已安装过
进行再删除
D:\Java\mysql-5.7.35-winx64\bin>sc delete mysql
[SC] DeleteService 成功
即可安装Mysql
D:\Java\mysql-5.7.35-winx64\bin>mysqld -install
Service successfully installed.
输入mysqld --initialize --user=root --console(,初始化,创建root账户.可直接复制)
运行后
…
…到最后一行
[Note] A temporary password is generated for root@