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"

  • 21
    点赞
  • 65
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值