mysql 8.0找不到my.ini配置文件解决方案

Posted 一代小强

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql 8.0找不到my.ini配置文件解决方案相关的知识,希望对你有一定的参考价值。

mysql 8.0 来了,该更新版本了”

  为了方便日后的工作,在这里整理了一下mysql的基本配置

新建my.ini配置文件

有些时候需要设置mysql的属性,一般的可以通过以下方式找到my.ini文件的路径

mysql> show variables like 'datadir';
+---------------+--------------------------------------------+
| Variable_name | Value                                      |
+---------------+--------------------------------------------+
| datadir       | C:\\ProgramData\\MySQL\\MySQL Server 8.0\\ |
+---------------+--------------------------------------------+
1 row in set (0.03 sec)

执行结果就是配置文件的路径

:可以通过select @@basedir; 获取到mysql的安装路径

但是笔者的mysql有点傲娇,不太一样:

mysql> show variables like 'datadir';
+---------------+--------------------------------------------+
| Variable_name | Value                                      |
+---------------+--------------------------------------------+
| datadir       | C:\\install\\mysql\\mysql-8.0.16-winx64\\data\\ |
+---------------+--------------------------------------------+
1 row in set (0.03 sec)

并且该目录下根本就没有my.ini配置文件。。。。。

嘿嘿~~ 那就新建一个!

比如在这里新建一个空的my.ini:

C:\\install\\mysql\\mysql-8.0.16-winx64\\my.ini

内容可以copy一份这里的:

# 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:\\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

或者只加入自己想要的配置,例如:

[mysqld]
ft_min_word_len=1

然后打开cmd,进入命令行,输入:


mysqld  --defaults-file="C:\\install\\mysql\\mysql-8.0.16-winx64\\my.ini"

即修改mysql的配置文件路径,嘿嘿 _

重启mysql服务即可,查看是否生效,可以执行类似的命令:

mysql>  show variables like '%ft%';
+---------------------------------+----------------+
| Variable_name                   | Value          |
+---------------------------------+----------------+
| ft_boolean_syntax               | + -><()~*:""&| |
| ft_min_word_len                 | 1              |  
+---------------------------------+----------------+
17 rows in set (0.03 sec)

如果还没有安装mysql服务,那更加好,只需要在安装的时候输入即可:


mysqld --install "MySql80" --defaults-file="C:\\install\\mysql\\mysql-8.0.16-winx64\\my.ini"

以上是关于mysql 8.0找不到my.ini配置文件解决方案的主要内容,如果未能解决你的问题,请参考以下文章

mysql配置问题mysql找不到VCRUNTIME140_1.DLL,无法继续执行,my.ini 配置文件

Mysql如何配置my.ini文件?

MySQL数据库,my.ini文件缺少参数。。

安装mysql没有my.ini文件

mysql8 安装无my.ini配置文件和执行groupBy报错修改sql_mode不生效的解决方案

Mysql 8.0 配置主从备份