MySQL or MariaDB config basics
Topic: Databases core
Summary
MySQL and MariaDB use my.cnf or my.ini for configuration. Key settings include datadir, port, bind-address, max_connections, and buffer pool. Use this when tuning or securing the server.
Intent: How-to
Quick answer
- Config files: /etc/mysql/my.cnf or /etc/my.cnf; often includes files in conf.d. Sections [mysqld], [client]. Change datadir, port, bind-address as needed. Restart to apply most changes.
- innodb_buffer_pool_size for InnoDB (often 70-80 percent of RAM for dedicated DB). max_connections for concurrency. Set character-set-server and collation for encoding.
- Verify with SHOW VARIABLES. Use SET GLOBAL for temporary changes; persist in config for permanent. Document changes for disaster recovery.
Prerequisites
Steps
-
Locate and edit config
Find my.cnf; edit [mysqld] section. Common: datadir, port, bind-address, max_connections, innodb_buffer_pool_size. Save.
-
Apply changes
Restart MySQL/MariaDB for most options. Some variables are SET GLOBAL. systemctl restart mysql or mariadb.
-
Verify
SHOW VARIABLES LIKE 'innodb_buffer_pool_size'; and others. Confirm encoding and connectivity.
Summary
Edit my.cnf for datadir, port, buffer pool, and encoding; restart to apply; verify with SHOW VARIABLES.
Prerequisites
Steps
Step 1: Locate and edit config
Edit my.cnf [mysqld]; set datadir, port, bind-address, buffer pool, and encoding.
Step 2: Apply changes
Restart the server; use SET GLOBAL only for temporary overrides.
Step 3: Verify
Use SHOW VARIABLES to confirm settings and encoding.
Verification
- SHOW VARIABLES shows intended values; server accepts connections.
Troubleshooting
Server won’t start — Check syntax and paths in my.cnf; check error log. Setting ignored — Some options require restart; check docs for scope.