MySQL配置文件配置

MySQL配置文件配置MySQL配置文件

大家好,又见面了,我是你们的朋友全栈君。


前言

本文主要介绍MySQL配置文件(my.cnf)


测试环境

虚拟机环境:VirtualBox 6.0.24
操作系统:Oracle Linux Server release 6.5 x86_64
MySQL版本:5.7.33


MySQL配置文件在哪里?

确定MySQL的配置文件路径


[root@rac02 ~]# mysql --help|grep my.cnf
                      order of preference, my.cnf, $MYSQL_TCP_PORT,
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf /usr/local/mysql/bin/my.cnf ~/.my.cnf
通过以上命令可以看出,mysql启动是会有一个读取配置文件的优先顺序
[root@rac02 ~]# locate my.cnf
/etc/my.cnf
#本环境中mysql的配置文件

my.cnf配置文件说明

默认配置文件查看:

[mysqld]
datadir = /usr/local/mysql/mysql-files
socket = /usr/local/mysql/mysql-files/mysql.sock
user = mysql
symbolic-links=0


[client]
socket = /usr/local/mysql/mysql-files/mysql.sock
  1. [mysqld]、[client],这些中括号代表的是组。

  2. “组”是要为其设置选项的程序或组的名称。在组行之后,任何选项设置行都将应用于命名组,直到选项文件的末尾或给出另一个组行。选项组名不区分大小写。

  3. [mysqld]和[mysql]组分别应用于mysqld服务器和mysql客户端程序。

  4. [client]组允许您指定适用于所有客户端的选项。

  5. 还可以指定其他组名,如mysqldump、mysqladmin、mysqld1等等。

修改配置文件

示例如下:

[client]
default-character-set = utf8mb4
port = 3306
socket = /usr/local/mysql/mysql-files/mysql.sock

[mysql]
prompt = "\\U \\R:\\m:\\s [\d]> "
no_auto_rehash
show-warnings
default-character-set = utf8mb4
socket = /usr/local/mysql/mysql-files/mysql.sock

[mysqld]
user = mysql
port = 3306
symbolic-links = 0
server_id = 56102
basedir = /usr/local/mysql
datadir = /usr/local/mysql/mysql-files
socket = /usr/local/mysql/mysql-files/mysql.sock
pid_file = /usr/local/mysql/mysql-files/rac02.pid
character-set-server = utf8mb4
skip_name_resolve = 1

lock_wait_timeout = 3600
open_files_limit    = 65535
back_log = 1024
max_connections = 512
max_connect_errors = 1000000
table_open_cache = 1024
table_definition_cache = 1024
thread_stack = 512K
sort_buffer_size = 4M
join_buffer_size = 4M
read_buffer_size = 8M
read_rnd_buffer_size = 4M
bulk_insert_buffer_size = 64M
thread_cache_size = 768
interactive_timeout = 600
wait_timeout = 600
tmp_table_size = 32M
max_heap_table_size = 32M

log_error = /usr/local/mysql/mysql-files/error.log
log_error_verbosity = 3
slow_query_log = 1
slow_query_log_file = /usr/local/mysql/mysql-files/slow.log
long_query_time = 0.1
log_queries_not_using_indexes = 1
log_throttle_queries_not_using_indexes = 60
min_examined_row_limit = 100
log_slow_admin_statements = 1
log_slow_slave_statements = 1
log_bin = /usr/local/mysql/mysql-files/mysql_binlog
binlog_format = ROW
sync_binlog = 1
binlog_cache_size = 4M
max_binlog_cache_size = 2G     
max_binlog_size = 1G
binlog_rows_query_log_events = 1
binlog_checksum = CRC32
gtid_mode = ON
enforce_gtid_consistency = TRUE



key_buffer_size = 32M
myisam_sort_buffer_size = 128M

transaction_isolation = REPEATABLE-READ
innodb_buffer_pool_size = 500M
innodb_buffer_pool_instances = 4
innodb_data_file_path = ibdata1:12M:autoextend
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 32M
innodb_log_file_size = 200M
innodb_log_files_in_group = 3
innodb_max_undo_log_size = 1G

innodb_io_capacity = 400
innodb_io_capacity_max = 800
innodb_open_files = 65535
innodb_flush_method = O_DIRECT
innodb_lru_scan_depth = 4000
innodb_lock_wait_timeout = 10
innodb_rollback_on_timeout = 1
innodb_print_all_deadlocks = 1
innodb_online_alter_log_max_size = 4G
innodb_status_file = 1

innodb_status_output = 0
innodb_status_output_locks = 1
innodb_sort_buffer_size = 67108864
innodb_adaptive_hash_index = OFF



[mysqldump]
quick

以上配置文件中参数设置仅供参考,仅作为测试使用,生产环境需按需进行调整。
如有错误,请指正,非常感谢!


版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/137214.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • navicat激活码3月最新在线激活

    navicat激活码3月最新在线激活,https://javaforall.net/100143.html。详细ieda激活码不妨到全栈程序员必看教程网一起来了解一下吧!

    2022年3月14日
    48
  • 在Ubuntu上使用FreeFileSync同步文件

    在Ubuntu上使用FreeFileSync同步文件FreeFileSync可以在Windows,Linux,macOS上面运行。本文使用操作系统是Ubuntu18.04。安装FreeFileSync下载程序,并解压。$wgethttps://freefilesync.org/download/FreeFileSync_11.0_Linux.tar.gz$tarxvfFreeFileSync_11.0_Linux.tar.gz解压之后进入FreeFileSync文件夹,就可以双击运行程序了。我们可以创建一个启动器,这样我们可以从桌面运

    2022年5月16日
    44
  • 使用matlab对图像进行二值化处理

    使用matlab对图像进行二值化处理图像二值化就是将图像上的像素点的灰度值设置为 0 或 255 也就是将整个图像呈现出明显的黑白效果的过程 A imread D A thresh graythresh A 确定二值化阈值 B im2bw A thresh 对图像二值化

    2025年8月26日
    3
  • c++ vector下标_vectorat

    c++ vector下标_vectoratC语言(加了层语法糖的汇编)为了性能并不支持数组的越界检查,每次检查会多付出2-3倍的时间。而vector以at的形式支持越界检查,但也支持C语言风格的[]高效访问,没错C++提供了足够的自由。当要获取std::vector的第n个元素,下面几种方式都可以:  std::vector<int>vec; size_tn=1; in…

    2022年9月27日
    3
  • ubuntu18.04 升级内核_ubuntu内核版本查看

    ubuntu18.04 升级内核_ubuntu内核版本查看ubuntu18.04.4更换内核版本

    2022年8月23日
    11
  • https加密原理(转)

    https加密原理(转)HTTP、HTTPS在我们日常开发中是经常会接触到的。我们也都知道,一般Android应用开发,在请求API网络接口的时候,很多使用的都是HTTP协议;使用浏览器打开网页,也是利用HTTP协议。看来HTTP真是使用广泛啊,但是,HTTP是不安全的。利用网络抓包工具就可以知道传输中的内容,一览无余。比如我经常会使用Fiddler来抓包,搜集一些有趣的API接口。那么…

    2022年5月20日
    39

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号