Configration
Server Configuration
Configuration File (my.cnf / my.ini)
ini
[mysqld]
# Basic Settings
port = 3306
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
user = mysql
# Performance Settings
innodb_buffer_pool_size = 1G
innodb_log_file_size = 256M
innodb_flush_log_at_trx_commit = 1
max_connections = 200
query_cache_size = 64M
# Security Settings
bind-address = 127.0.0.1
ssl-cert = /etc/mysql/server-cert.pem
ssl-key = /etc/mysql/server-key.pem
# Logging
log-error = /var/log/mysql/error.log
slow-query-log = 1
slow-query-log-file = /var/log/mysql/slow.log
long_query_time = 2
Memory Configuration
-
innodb_buffer_pool_size: Set to 70-80% of available RAM
-
max_connections: Adjust based on expected concurrent connections
-
query_cache_size: Configure for frequently executed queries
Security Configuration
sql
-- Enable SSL
SHOW VARIABLES LIKE 'have_ssl';
-- Configure user authentication
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
-- Set password validation
INSTALL COMPONENT 'file://component_validate_password';
Replication Configuration
ini
# Master Configuration
server-id = 1
log-bin = mysql-bin
binlog-format = ROW
gtid-mode = ON
enforce-gtid-consistency = ON
# Slave Configuration
server-id = 2
relay-log = mysql-relay-bin
read-only = 1