MySQL--My.cnf配置文件模板

Introduce

The MySQL and MariaDB default configuration is not very great for production use. Some of the default values in my.cnf should be changed when you need it for business critical applications.

The following MySQL configuration file is in our opinion a good average configuration file for MySQL, Galera Cluster, MariaDB and Percona Server. For MySQL servers more performance tuning is not need in most cases.

Download the sample MySQL and MariaDB configuration file with wget directly from here.

MySQL和MariaDB的默认配置对于生产环境使用来说并不是很好。当您的关键业务需要应用程序时,应更改my.cnf中的某些默认值。 我们认为以下MySQL配置文件是MySQL,Galera Cluster,MariaDB和Percona Server的良好平均配置文件。对于MySQL服务器,在大多数情况下不需要更多性能调整。 直接从这里下载带有wget的示例MySQL和MariaDB配置文件。

my.cnf模板

#
# FromDual configuration file template for MySQL, Galera Cluster, MariaDB and Percona Server
# Location: /etc/my.cnf or /etc/mysql/my.cnf
# This template is intended to work with MySQL 5.6 and newer and MariaDB 10.0 and newer
# Get most recent updated from here:
# http://www.fromdual.com/mysql-configuration-file-sample
#[client]port                           = 3306
socket                         = /var/run/mysqld/mysql.sock          # Use mysqld.sock on Ubuntu, conflicts with AppArmor otherwise[mysql]no_auto_rehash
max_allowed_packet             = 16M
prompt                         = '\u@\h [\d]> '                      # 'user@host [schema]> '
default_character_set          = utf8                                # Possibly this setting is correct for most recent Linux systems[mysqldump]max_allowed_packet             = 16M[mysqld_safe]                                                        # Becomes sooner or later obsolete with systemdopen_files_limit               = 8192                                # You possibly have to adapt your O/S settings as well
user                           = mysql
log-error                      = <hostname>_error.log          # Adjust AppArmor configuration: /etc/apparmor.d/usr.sbin.mysqld[mysqld]# Connection and Thread variablesport                           = 3306
socket                         = /var/run/mysqld/mysql.sock          # Use mysqld.sock on Ubuntu, conflicts with AppArmor otherwise
# basedir                        = /usr
# datadir                        = /var/lib/mysql
# tmpdir                         = /tmp
# innodb_tmpdir                  = /var/lib/mysql                      # MySQL 5.7max_allowed_packet             = 16M
default_storage_engine         = InnoDB
# explicit_defaults_for_timestamp = 1                                  # MySQL 5.6, test carefully! This can have an impact on application.
# disable_partition_engine_check  = true                               # Since MySQL 5.7.17 to 5.7.20. To get rid of nasty message in error log# character_set_server           = utf8                                # If you prefer utf8
# collation_server               = utf8_general_cimax_connections                = 505                                 # Values < 1000 are typically good
max_user_connections           = 500                                 # Limit one specific user/application
thread_cache_size              = 505                                 # Up to max_connections makes sense# Query Cachequery_cache_type               = 1                                   # Set to 0 to avoid global QC Mutex
query_cache_size               = 32M                                 # Avoid too big (> 128M) QC because of QC clean-up lock!# Session variablessort_buffer_size               = 2M                                  # Could be too big for many small sorts
tmp_table_size                 = 32M                                 # Make sure your temporary results do NOT contain BLOB/TEXT attributesread_buffer_size               = 128k                                # Resist to change this parameter if you do not know what you are doing
read_rnd_buffer_size           = 256k                                # Resist to change this parameter if you do not know what you are doing
join_buffer_size               = 128k                                # Resist to change this parameter if you do not know what you are doing# Other buffers and cachestable_definition_cache         = 1400                                # As big as many tables you have
table_open_cache               = 2000                                # connections x tables/connection (~2)
table_open_cache_instances     = 16                                  # New default in 5.7# MySQL error loglog_error                      = &lt;hostname&gt;_error.log            # Adjust AppArmor configuration: /etc/apparmor.d/usr.sbin.mysqld
# log_timestamps                 = SYSTEM                              # MySQL 5.7, equivalent to old behaviour
log_warnings                   = 2
# log_error_verbosity            = 3                                   # MySQL 5.7, equivalent to log_warnings = 2
# innodb_print_all_deadlocks     = 1
# wsrep_log_conflicts            = 1                                   # for Galera only!# Slow Query Logslow_query_log_file            = &lt;hostname&gt;_slow.log              # Adjust AppArmor configuration: /etc/apparmor.d/usr.sbin.mysqld
slow_query_log                 = 0
log_queries_not_using_indexes  = 0
long_query_time                = 0.5
min_examined_row_limit         = 100# General Query Loggeneral_log_file               = &lt;hostname&gt;_general.log           # Adjust AppArmor configuration: /etc/apparmor.d/usr.sbin.mysqld
general_log                    = 0# Performance Schema# performance_schema             = ON                                  # on some older MariaDB 10 releases
performance_schema_consumer_events_statements_history_long = ON      # MySQL 5.6 and newer# Binary logging and Replicationserver_id                      = 42
log_bin                        = &lt;hostname&gt;_binlog                     # Locate outside of datadir, adjust AppArmor configuration: /etc/apparmor.d/usr.sbin.mysqld
# master_verify_checksum         = ON                                  # MySQL 5.6
binlog_cache_size              = 1M
binlog_stmt_cache_size         = 1M
max_binlog_size                = 128M                                # Make bigger for high traffic to reduce number of files
sync_binlog                    = 0                                   # Set to 1 or higher to reduce potential loss of binary-log data
expire_logs_days               = 5                                   # We will survive easter holidays
binlog_format                  = ROW                                 # Use MIXED if you experience some troubles
# binlog_row_image               = MINIMAL                             # Since 5.6
# auto_increment_increment       = 2                                   # For Master/Master set-ups use 2 for both nodes
# auto_increment_offset          = 1                                   # For Master/Master set-ups use 1 and 2# Slave variableslog_slave_updates              = 1                                   # Use if Slave is used for Backup and PiTR
read_only                      = 0                                   # Set to 1 to prevent writes on Slave
# super_read_only                = 0                                   # Set to 1 to prevent writes on Slave for users with SUPER privilege. Since 5.7
# skip_slave_start               = 1                                   # To avoid start of Slave thread
# relay_log                      = &lt;hostname&gt;-relay-bin
# relay_log_info_repository      = table                               # MySQL 5.6
# master_info_repository         = table                               # MySQL 5.6
# slave_load_tmpdir              = '/tmp'# Crash-safe replication Master# binlog_checksum                = CRC32                               # default
# sync_binlog                    = 1                                   # default since 5.7.6, but slow!
# innodb_support_xa              = 1                                   # default, depracted since 5.7.10# Crash-safe replication Slave# master_info_repository         = TABLE
# relay_log_info_repository      = TABLE
# relay_log_recovery             = 1
# sync_relay_log_info            = 1
# relay_log_purge                = 1                                   # default
# slave_sql_verify_checksum      = 1                                   # default# GTID replication# gtid_mode                        = ON                                  # Master and Slave
# enforce_gtid_consistency         = 1                                   # Master and Slave# log_bin                          = %INSTANCEDIR%/binlog/%UNAME%_%INSTANCE%_binlog   # In 5.6 also on Slave
# log_slave_updates                = 1                                   # In 5.6 also on Slave# Security variables# local_infile                   = 0                                   # If you are security aware
# secure_auth                    = 1                                   # If you are security aware
# sql_mode                       = TRADITIONAL,ONLY_FULL_GROUP_BY,NO_ENGINE_SUBSTITUTION,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER   # Be careful changing this afterwards
# skip_name_resolve              = 0                                   # Set to 1 if you do not trust your DNS or experience problems
# secure_file_priv               = '/tmp'                              # chmod 750, adjust AppArmor configuration: /etc/apparmor.d/usr.sbin.mysqld# MyISAM variableskey_buffer_size                = 8M                                  # Set to 25 - 33 % of RAM if you still use MyISAM
myisam_recover_options         = 'BACKUP,FORCE'
# disabled_storage_engines       = 'MyISAM,MEMORY'                     # MySQL 5.7, do NOT during/before mysql_upgrade, good for Galera!# MEMORY variablesmax_heap_table_size            = 64M                                 # Should be greater or equal to tmp_table_size# InnoDB variablesinnodb_strict_mode             = ON
innodb_file_format_check       = 1
# innodb_file_format             = Barracuda                           # For dynamic and compressed InnoDB tables
innodb_buffer_pool_size        = 128M                                # Go up to 80% of your available RAM
innodb_buffer_pool_instances   = 8                                   # Bigger if huge InnoDB Buffer Pool or high concurrencyinnodb_file_per_table          = 1                                   # Is the recommended way nowadays
# innodb_flush_method            = O_DIRECT                            # O_DIRECT is sometimes better for direct attached storage
# innodb_write_io_threads        = 8                                   # If you have a strong I/O system or SSD
# innodb_read_io_threads         = 8                                   # If you have a strong I/O system or SSD
# innodb_io_capacity             = 1000                                # If you have a strong I/O system or SSDinnodb_flush_log_at_trx_commit = 2                                   # 1 for durability, 0 or 2 for performance
innodb_log_buffer_size         = 8M                                  # Bigger if innodb_flush_log_at_trx_commit = 0
innodb_log_file_size           = 256M                                # Bigger means more write throughput but longer recovery time# Galera specific MySQL parameter# default_storage_engine         = InnoDB                            # Galera only works with InnoDB
# innodb_flush_log_at_trx_commit = 2                                 # Durability is achieved by committing to the Group
# innodb_autoinc_lock_mode       = 2                                 # For parallel applying
# binlog_format                  = row                               # Galera only works with RBR
# query_cache_type               = 0                                 # Use QC with Galera only in a Master/Slave set-up
# query_cache_size               = 0# WSREP parameter# wsrep_on                       = on                                  # Only MariaDB >= 10.1
# wsrep_provider                 = none                                # Start mysqld without Galera
# wsrep_provider                 = /usr/lib/galera/libgalera_smm.so    # Location of Galera Plugin on Ubuntu ?
# wsrep_provider                 = /usr/lib64/galera-3/libgalera_smm.so   # Location of Galera Plugin on CentOS 7
# wsrep_provider_options         = 'gcache.size = 1G'                  # Depends on you workload, WS kept for IST# wsrep_cluster_name             = "My cool Galera Cluster"            # Same Cluster name for all nodes
# wsrep_cluster_address          = "gcomm://"                          # Old bootstrap method
# wsrep_cluster_address          = "gcomm://192.168.0.2,192.168.0.3"   # Start other nodes like this# wsrep_node_name                = "Node A"                            # Unique node name
# wsrep_node_address             = 192.168.0.1                         # Our address where replication is done
# wsrep_node_incoming_address    = 10.0.0.1                            # Our external interface where application comes from
# wsrep_sync_wait                = 1                                   # If you need realy full-synchronous replication (Galera 3.6 and newer)
# wsrep_slave_threads            = 16                                  # 4 - 8 per core, not more than wsrep_cert_deps_distance# wsrep_sst_method               = rsync                               # SST method (initial full sync): mysqldump, rsync, rsync_wan, xtrabackup-v2
# wsrep_sst_auth                 = sst:secret                          # Username/password for sst user
# wsrep_sst_receive_address      = 192.168.0.1                         # Our address where to receive SST# Group Replication parameter# default_storage_engine         = InnoDB                              # Group Replication only works with InnoDB
# server_id                      = %SERVERID%                          # Should be different on all 3 nodes
# log_bin                        = %INSTANCEDIR%/binlog/%UNAME%_%INSTANCE%_binlog   # Locate outside of datadir, adjust AppArmor configuration: /etc/apparmor.d/local/usr.sbin.mysqld
# binlog_format                  = ROW
# binlog_checksum                = NONE                                # not default!
# gtid_mode                      = ON
# enforce_gtid_consistency       = ON
# master_info_repository         = TABLE
# relay_log_info_repository      = TABLE
# log_slave_updates              = ON# slave_parallel_workers         = &lt;n&gt;                                 # 1-2/core, max. 10
# slave_preserve_commit_order    = ON
# slave_parallel_type            = LOGICAL_CLOCK# transaction_write_set_extraction            = XXHASH64# loose-group_replication_group_name          = "$(uuidgen)"           # Must be the same on all nodes
# loose-group_replication_start_on_boot       = OFF
# loose-group_replication_local_address       = "192.168.0.1"
# loose-group_replication_group_seeds         = "192.168.0.1,192.168.0.2,192.168.0.3"   # All nodes of Cluster
# loose-group_replication_bootstrap_group     = OFF
# loose-group_replication_single_primary_mode = FALSE                  # = multi-primary

转载来源:https://www.fromdual.com/mysql-configuration-file-sample

MySQL--My.cnf配置文件模板 MYSQL AND MARIADB CONFIGURATION FILE TEMPLATE (MY.CNF/MY.INI)相关推荐

  1. mysql变量环境配置文件_Day44 Mysql环境变量、配置文件(2)

    目录:环境变量配置及系统服务制作 设置密码 忘记密码情况 配置文件的修改 1.环境变量配置及系统服务制作 # 查看具体进程 # tasklist # tasklist | findstr mysqld ...

  2. mysql my.cnf在哪里_my.cnf配置文件在哪

    my.cnf配置文件在linux上是位于路径"/etc/my.cnf"下,在window上则位于安装目录的根目录下:可以使用命令"mysql --help"查看 ...

  3. mysql模板文件_Mysql配置文件模板

    来自: http://www.fromdual.com/mysql-configuration-file-sample The MySQL and MariaDB default configurat ...

  4. MySQL无法启用/etc/my.cnf配置文件,重启报错Warning: World-writable config file ‘/etc/my.cnf’ is ignored的解决方法

    MySQL无法启用/etc/my.cnf配置文件,重启报错Warning: World-writable config file '/etc/my.cnf' is ignored的解决方法 问题分析 ...

  5. MySQL无法重启问题解决Warning: World-writable config file '/etc/my.cnf' is ignored

    为什么80%的码农都做不了架构师?>>>    今天帮朋友维护服务器,在关闭数据库的命令发现mysql关不了,提示Warning: World-writable config fil ...

  6. MySQL重启也无法解决的Warning: World-writable config file '/etc/mysql/my.cnf' is ignored

    故障现象: 手残把配置文件'/etc/mysql/my.cnf' 的权限设置成 "777" 了,在centos7.6环境下,使用rpm包方式安装的mysql5.7.29,在使用命令 ...

  7. zabbix mysql监控告警_Zabbix监控mysql配置及故障告警配置

    同时介绍了触发器的创建及zabbix通过邮件方式告警配置. 一.配置自带模板监控mysql 1.提供配置文件模板 文件位置在源码包/usr/local/src/zabbix-3.0.4/conf/za ...

  8. MySQL第4天:MySQL的架构介绍之修改数据库编码格式

    MySQL的架构介绍之修改数据库编码格式 1.配置文件介绍 #编写时间:2017.3.6 #编写地点:广州 上一篇文章可知mysql的配置文件在:/usr/share/mysql,其中/usr/sha ...

  9. mysql5.1怎么备份,MySQL 5.1升级到MySQL 5.5的步骤

    mysql 5.5已经出来有一段时间,性能有明显提升,特别是对多核CPU的支持与TPS性能的提升.上周博主介绍了linux下编译安装mysql 5.5的步骤,安装不出意外基本没有问题.不过可能很多朋友 ...

最新文章

  1. LeetCode实战:最大子序和
  2. The prefix “mvc“ for element “mvc:annotation-driven“ is not bound 异常
  3. CSS干货直击:腾讯无边界访问控制体系建设
  4. AD制图相关问题总结
  5. Git入门教程(一)
  6. python解析不完全的html_【已解决】Scrapy的Python中如何解析部分的html字符串并格式化为html网页源码...
  7. 一份 Hadoop 面试 【避坑指南】 拍了拍你!
  8. css中背景的应用及BFC与IFC应用
  9. JDBC+Servlet+JSP实现基本的增删改查(简易通讯录)
  10. 【图像分割】基于matlab FCM侧扫声呐图像分割【含Matlab源码 1478期】
  11. MySQL保存历史执行语句
  12. 9 matlab入门求一元二元函数的最小值和零点
  13. 迅捷fw325r虚拟服务器设置,迅捷FAST FW325R路由器无线桥接设置方法
  14. 勒索病毒基础介绍,值得收藏
  15. CSS第7章上机练习1(制作QQ会员页面导航)
  16. [算法总结] LCA倍增法 dfs
  17. matlab+cummean,matlab常用操作备忘(2)
  18. udev (简体中文)
  19. mata name,property=og:title|og:image的几种说明
  20. c语言程序设计振动合成,C语言课程设计-振动波的合成原理

热门文章

  1. PHP 比较两个文本文件差异 A diff implementation for PHP
  2. Magento教程 13:在Magento中设定联络表单的收件信箱
  3. CSS3 Media Query 响应式媒体查询
  4. iPad网页开发教程及规则
  5. Python实例讲解 -- wxpython 基本的控件 (文本)
  6. C++—— cin输入流详解
  7. PixelShuffle特征图的上采样的方法
  8. Java—这把线程池ThreadPoolExecutor操作,你学会了吗?
  9. 关于封装 c# 115691143
  10. 前端开发 认识css 体验变色的效果 0228