zip安装的MySQL绑定my.ini配置文件

删除MySQL服务

管理员CMD

sc delete MySQL


控制台删除之后需要打开任务管理器,因为有可能在删除MySQL服务的过程中,MySQL已经在运行了,如果是运行情况下我们删除了MySQL,这并不会使得MySQL及时停止,需要手动找到这个进程关闭一下。

增加my.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]
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
datadir = D:MySQLdata
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

将上面的配置清单复制下来,然后在MySQL的根目录下创建my.ini文件,打开此文件之后将配置清单copy进去。需要注意的是安装目录basedir、datadir记得改成自己的位置。

重新生成data文件

删除之前生成的data文件,如果有数据表可以先备份,删除之后重新生成即可

mysqld --initialize-insecure --use=mysql

重新安装MySQL服务

mysqld --install "MySQL8.0" --defaults-file="D:mysql-8.0.23my.ini"

启动MySQL

net start MySQL8.0

你猜怎么着。。。启动失败了,仔细检查一下上面在重新安装data文件的时候把user写成了use。。。那么只需要再删除data用正确的命令生成data再执行就行。



删除了data并重新生成之后,之前创建的数据库用户和密码都会被清理掉的哈,记得再添加一下

原文地址:https://www.cnblogs.com/mirage-mc/p/14547746.html