my.cnf

See Database Management Systems.

There is a small text file called my.cnf that is part of the MySQL/MariaDB installation for Linux servers. Below is an example of the my.cnf settings. Restart the MySQL service after making changes to my.cnf.

MariaDB 10.5 MyISAM Example

[mysqld]

datadir=/var/lib/mysql

default-storage-engine=MyISAM

max_allowed_packet=40M

lower_case_table_names=1

port=3306

sql_mode=''

explicit_defaults_for_timestamp=1

key_buffer_size=3G

myisam_recover_options=OFF

optimizer_switch=split_materialized=OFF


MySQL 5.5 MyISAM Example

Note: This example is untested.

[mysqld]

datadir=/var/lib/mysql

default-storage-engine=MyISAM

skip-innodb

max_allowed_packet=40M

lower_case_table_names=1


MySQL 5.5 InnoDB Example

Note: This example is untested.

[mysqld]port = 3306

socket = /var/run/mysqld/mysql.sock

default_character_set = utf8

default_storage_engine = InnoDB

max_connections = 500

max_user_connections = 500

lower_case_table_names = 1

max_allowed_packet = 40M

max_connect_errors = 1000

skip_name_resolve

binlog_format = ROW

expire_logs_days = 4

sync_binlog = 1

tmp_table_size = 64M

max_heap_table_size = 64M

query_cache_type = 0

query_cache_size = 0

thread_cache_size = 500

open_files_limit = 65535

table_definition_cache = 1024

table_open_cache = 1024

net_buffer_length = 16K

thread_stack = 512K

sort_buffer_size = 2M

read_buffer_size = 2M

read_rnd_buffer_size = 8M

join_buffer_size = 128M

binlog_cache_size = 1M

innodb_flush_method = O_DIRECT

innodb_log_files_in_group = 3

innodb_log_file_size = 1G

innodb_flush_log_at_trx_commit = 1

innodb_file_per_table = 1

innodb_buffer_pool_size = 1G

innodb_locks_unsafe_for_binlog = 1

innodb_autoinc_lock_mode = 2

interactive_timeout = 500

wait_timeout = 500

connect_timeout = 10

slow_query_log = 1

slow_query_log_file = mysql-slow.log