MySQL 5.7 version parameter optimization

  1. innodb_buffer_pool_size: The buffer pool size of the InnoDB storage engine. It is generally recommended to set it to 70%-80% of the system memory.
  2. innodb_log_buffer_size: The log cache size of the InnoDB storage engine, it is generally recommended to set it to 16M.
  3. innodb_flush_log_at_trx_commit: The InnoDB storage engine writes the log to the disk when the transaction is committed. It has three values: 0, 1, and 2. Among them, 1 is the default value, which means that the log is written to the disk every time the transaction is committed. Whereas 0 means that the log is not written to disk, but is stored in the operating system cache, and 2 means that the log is written to disk once per second. It is recommended to set it to 1 to ensure data security.
  4. innodb_flush_method: The way the InnoDB storage engine flushes data to the disk. Its values ​​include O_DSYNC, O_DIRECT, fsync, fsync_nosync and other methods. Among them, O_DIRECT is the default value, which means that the data is flushed to the disk by direct I/O. It is recommended to use the way.
  5. innodb_file_per_table: Whether to create an independent table space for each InnoDB table, it is recommended to enable this function.
  6. innodb_io_capacity: The disk I/O capability of the InnoDB storage engine, it is usually recommended to set it to the IOPS value of the disk.
  7. innodb_thread_concurrency: The thread concurrency of the InnoDB storage engine. It is recommended to set it to twice the number of CPU cores.
  8. max_connections: The maximum number of connections to the MySQL server, it is generally recommended to set it to 1/4-1/3 of the system memory.
  9. key_buffer_size: The index cache size of the MyISAM storage engine, it is recommended to set it to 1/3 of the size of all indexes.
  10. query_cache_size: The query cache size of the MySQL server, it is recommended to set it to 8MB-128MB.

Guess you like

Origin blog.csdn.net/weixin_42456784/article/details/129929496