MySQL配置文件配置
生活随笔
收集整理的這篇文章主要介紹了
MySQL配置文件配置
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
目錄
- 前言
- 測試環境
- MySQL配置文件在哪里?
- my.cnf配置文件說明
- 修改配置文件
前言
本文主要介紹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.cnforder 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 = 1lock_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 = 32Mlog_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 = TRUEkey_buffer_size = 32M myisam_sort_buffer_size = 128Mtransaction_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 = 1Ginnodb_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 = 1innodb_status_output = 0 innodb_status_output_locks = 1 innodb_sort_buffer_size = 67108864 innodb_adaptive_hash_index = OFF[mysqldump] quick以上配置文件中參數設置僅供參考,僅作為測試使用,生產環境需按需進行調整。
如有錯誤,請指正,非常感謝!
總結
以上是生活随笔為你收集整理的MySQL配置文件配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 直接从chrome中复制的body到po
- 下一篇: Vue.js + Nuxt.js 项目中