获取Mysql压缩包
下载地址
https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.12-winx64.zip
解压
获取到之后直接解压文件。
创建my.ini文件
首先新建文本文档,然后对其重命名。若无法重命名后缀则在显示下将文件扩展名点上就可以了
将以下内容复制到my.ini中
其中 datadir路径不可缺少 \data
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_bin
init_connect='SET NAMES utf8mb4'
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
basedir = D:\mysql-8.0.25-winx64 # 修改为你的mysql所在位置
datadir = D:\mysql-8.0.25-winx64\data# 修改为你的mysql所在位置并一定在后边加上\data
port = 3306
# server_id = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
join_buffer_size = 128M
sort_buffer_size = 16M
read_rnd_buffer_size = 16M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
创建服务
在bin文件夹下打开命令行(管理员模式 )然后输入
mysqld --initialize-insecure --user=mysql
然后再输入
mysqld --install "MySql80"
这样服务就创建完成了
启动服务
net start mysql80
如果启动不成功 请检查my.ini里边路径是否正确