Mysql

关注公众号 jb51net

关闭
首页 > 数据库 > Mysql > mysql8.0找不到my.ini配置文件

mysql8.0找不到my.ini配置文件的问题及解决

作者:一代小强

这篇文章主要介绍了mysql8.0找不到my.ini配置文件的问题及解决方案,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教

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"

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

您可能感兴趣的文章:
阅读全文