1,首先我按照了网上的打开隐藏文件,还是找不到my.ini(打开隐藏文件的方法:
2,如果1方法找到了。。就不用看2了。如果没找到就接受现实,需要自己创建my.ini然后重新配置。
(1)管理员运行cmd,前提是配置了mysql环境,输入如下删除mysql服务:
sc delete Mysql80
(2)在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 = S:\mysql\mysql-8.0.17-winx64
datadir = S:\mysql\mysql-8.0.17-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
basedir = S:\mysql\mysql-8.0.17-winx64
datadir = S:\mysql\mysql-8.0.17-winx64\data 根据自己程序所在地写
(4)对data数据进行备份
我是使用的navicat对数据库进行备份,如下:
然后删除data文件夹,在cmd中输入(此时会重新生成data文件夹):
mysqld --initialize-insecure --user=mysql
(5)绑定my.ini文件:
mysqld --install "mysql" --defaults-file="S:\mysql\mysql-8.0.17-winx64\my.ini"
(6)安装好了,使用cmd启动就可以了。此时初始密码为空,启动时需要输密码直接回车就好啦。
标签:set,data,server,ini,mysql,根目录,my
来源: https://blog.csdn.net/weixin_45100596/article/details/100085122