MySQL介绍五:MySQL配置文件my.ini,部分配置项介绍;(这篇博客很重要!!!)

这篇博客,虽然没有什么SQL语句介绍,但是是十分重要的!!!

目录

1.my.ini配置文件简介:

 2.my.ini部分配置项介绍

3.注:再啰嗦一下,每次修改my.ini配置文件后,如果想让其生效,必须经过以下步骤:

4.net stop mysql后,mysql服务就停滞了,无法使用了


1.my.ini配置文件简介:

MySQL的配置文件是my.ini,在MySQL的数据存储目录:

(注:可变色的记事本工具,可以使用NotePad++,也可以使用微软提供的VSCode)

使用VSCode打开my.ini:

删掉my.ini文件的注释:否则my.ini太长了,不方便看;

修改my.ini文件后,保存的时候,发现权限不够,自己设置一下,但后来搞砸了,还是不行。。。。最后的解决办法是:将my.ini内容复制出来,保存到另一个新文件中,将原my.ini文件删掉,然后将新文件名字改为my.ini,将这个新的my.ini复制进【C:\ProgramData\MySQL\MySQL Server 8.0】目录下。。。。目前看来,没什么问题,,,

[client]
port=3306

[mysql]
no-beep

[mysqld]
port=3306   #端口号
datadir=C:/ProgramData/MySQL/MySQL Server 8.0\Data #数据目录
default_authentication_plugin=mysql_native_password #密码认证插件
default-storage-engine=INNODB #默认存储引擎
sql-mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION" #开启严格模式
log-output=FILE #用文件记录日志
general-log=0 #关闭日志输出
general_log_file="DESKTOP-P1FU27H.log" #日志文件名称
slow-query-log=1 #开启慢查询日志
slow_query_log_file="DESKTOP-P1FU27H-slow.log" #慢查询日志文件名称
long_query_time=10 #大于多少秒的执行SQL被记录在慢查询日志
log-error="DESKTOP-P1FU27H.err" #错误日志名称
log-bin="DESKTOP-P1FU27H-bin" #
server-id=1 # 数据库ID
lower_case_table_names=1 #把表名转换成小写
secure-file-priv="C:/ProgramData/MySQL/MySQL Server 8.0/Uploads" #导入导出数据的目录地址
max_connections=151 #最大连接
table_open_cache=2000
tmp_table_size=138M
thread_cache_size=10 #线程数量
myisam_max_sort_file_size=100G
myisam_sort_buffer_size=266M
key_buffer_size=8M
read_buffer_size=64K
read_rnd_buffer_size=256K
innodb_flush_log_at_trx_commit=1
innodb_log_buffer_size=1M
innodb_buffer_pool_size=8M
innodb_log_file_size=48M
innodb_thread_concurrency=17
innodb_autoextend_increment=64
innodb_buffer_pool_instances=8
innodb_concurrency_tickets=5000
innodb_old_blocks_time=1000
innodb_open_files=300
innodb_stats_on_metadata=0
innodb_file_per_table=1
innodb_checksum_algorithm=0
back_log=80
flush_time=0
join_buffer_size=256K
max_allowed_packet=4M
max_connect_errors=100
open_files_limit=4161
sort_buffer_size=256K
table_definition_cache=1400
binlog_row_event_max_size=8K
sync_master_info=10000
sync_relay_log=10000
sync_relay_log_info=10000
loose_mysqlx_port=33060

 2.my.ini部分配置项介绍

逐条解释如下:


3.注:再啰嗦一下,每次修改my.ini配置文件后,如果想让其生效,必须经过以下步骤:

第一步:关闭mysql服务:

net stop mysql80

第二步:加载下配置文件(这一步,应该是需要的吧…):

mysqld --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" --console

然后【Ctrl + C】关闭mysqld服务;

然后关闭PowerShell,重新以为管理员身份打开一个新的PowerShell窗口:

第三步:重启mysql服务

net start mysql80


4.net stop mysql后,mysql服务就停滞了,无法使用了

……………………………………………………

 

 

 

 

  • 11
    点赞
  • 50
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
好的,下面是一个 MySQL 5.7.31 的 my.ini 配置文件示例: ``` # MySQL Server Instance Configuration File # ---------------------------------------------------------------------- # Generated by the MySQL Server Instance Configuration Wizard # # Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # The MySQL Server configuration file. # # For explanations see # http://dev.mysql.com/doc/mysql/en/server-system-variables.html [client] port=3306 [mysql] default-character-set=utf8mb4 [mysqld] port=3306 bind-address=127.0.0.1 datadir=C:/ProgramData/MySQL/MySQL Server 5.7/Data character-set-server=utf8mb4 collation-server=utf8mb4_unicode_ci lower_case_table_names=1 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES # General logging. log-output=FILE general-log=0 general_log_file="C:/ProgramData/MySQL/MySQL Server 5.7/Data/MyServer.log" # Error logging. log-error="C:/ProgramData/MySQL/MySQL Server 5.7/Data/MyServer.err" # InnoDB Configuration innodb_buffer_pool_size=16M # Custom config should go here ``` 这是一个基本的配置文件,可以根据需要进行修改。例如,可以更改端口号、绑定地址、数据目录等等。
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值