微信扫一扫 分享朋友圈

已有 29 人浏览分享

开启左侧

MySQL配置文件如何设置

[复制链接]
29 0
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

[mysqld]、[client],这些中括号代表的是组。
“组”是要为其设置选项的程序或组的名称。在组行之后,任何选项设置行都将应用于命名组,直到选项文件的末尾或给出另一个组行。选项组名不区分大小写。
[mysqld]和[mysql]组分别应用于mysqld服务器和mysql客户端程序。
[client]组允许您指定适用于所有客户端的选项。
还可以指定其他组名,如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


免责声明:
1,海欣资源网所发布的资源由网友上传和分享,不保证信息的正确性和完整性,且不对因信息的不正确或遗漏导致的任何损失或损害承担责任。
2,海欣资源网的资源来源于网友分享,仅限用于学习交流和测试研究目的,不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。
3,海欣资源网所发布的资源由网友上传和分享,版权争议与本站无关,您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。
4,如果您喜欢,请支持正版,购买正版,得到更好的正版服务,如有侵权,请联系我们删除并予以真诚的道歉,联系方式邮箱 haixinst@qq.com
海欣资源-企业信息化分享平台。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

0

关注

0

粉丝

30

主题
热度排行
回复排行
最新贴子

Archiver|手机版|海欣资源 ( 湘ICP备2021008090号-1 )|网站地图

GMT+8, 2024-12-4 01:36 , Gzip On, MemCached On.

免责声明:本站所发布的资源和文章均来自网络,仅限用于学习交流和测试研究目的,不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。 本站信息来自网络,版权争议与本站无关,您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。 如果您喜欢,请支持正版,购买正版,得到更好的正版服务,如有侵权,请联系我们删除并予以真诚的道歉。