1.删除mysql服务
以管理员运行dos窗口卸载mysql服务
sc delete MySql
(建议先停止mysql服务)
重建ini文件
# 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]
ft_min_word_len = 1
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
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 = G:\2345Downloads\mysql-5.7.20-winx64
datadir = G:\2345Downloads\mysql-5.7.20-winx64\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
初始化date目录
以管理员身份运行cmd切换到mysql下的bin文件夹
运行mysqld --initialize
目的是为了初始化data目录
重新设置默认my.ini文件
mysqld --install MySQL --defaults-file="C:\MySQL\MySQL Server 5.7\my.ini“
C:\MySQL\MySQL Server 5.7\my.ini为你重新设置的ini文件所在位置然后运行mysqld --install
最后重启服务net start mysql