MySQL/Postgres Config Audit Guide
Last updated:
A database config audit is a static review of a database server’s configuration file — my.cnf for MySQL or postgresql.conf for PostgreSQL — checked line by line against known-good practice, without connecting to the server. The file is small, usually a few dozen settings, but it decides who can log in without a password, which network interfaces the server listens on, whether a crash loses committed transactions, and whether you can recover to a point in time. This guide walks through the settings that matter, the durability-versus-performance trade-off hiding in two numbers, the MySQL vs Postgres config split, and the mistakes that show up again and again — then shows you how to run the same audit yourself with the MySQL/Postgres Config Auditor.
What a database config audit actually checks
A config audit reads the file the way the server reads it: as a list of settings, one per line. MySQL groups them under [section] headers — [mysqld] for the server, [client] for clients — while PostgreSQL uses a flat list of key = value lines in postgresql.conf. Because a setting that is simply absent leaves the compiled-in default in force, an audit checks absence as carefully as presence: the line you never wrote can be the one that matters most.
The checks fall into four families. Authentication and access: who can connect, from where, and with what password rules. Transport security: whether connections are encrypted, and with what. Durability and recovery: what survives a crash, and whether you can replay to a point in time. And operational basics: logging, connection limits and memory — the settings whose absence is only noticed during an incident. The MySQL/Postgres Config Auditor runs these rules across both dialects and scores the result from 0 to 100; its companion, the Slow Query Log Analyzer, reads the logs the config enables, and the same audit family covers Apache and sshd configs.
The settings that decide your security posture
Five settings do most of the work. skip-grant-tables in MySQL disables authentication entirely — anyone who can reach the server is root, with no password at all. bind-address = 0.0.0.0 (MySQL) or listen_addresses = '*' (Postgres) makes the server listen on every interface, so a database meant for localhost is suddenly reachable from the whole network. local-infile = ON lets a client read arbitrary files from the server. ssl = off in Postgres, or skip-ssl in MySQL, sends every query — passwords included — in clear text. And password_encryption = md5 (Postgres) or default_authentication_plugin = mysql_native_password (MySQL) stores password hashes in a form that is fast to crack.
Then come the quieter ones. An empty secure-file-priv lets MySQL read and write files anywhere the server process can reach. general_log = ON writes every query — including literal passwords in statements — into a log file. No log_error at all means you are flying blind when something goes wrong. And a missing validate_password policy means a user can pick password123 and the server will accept it. None of these is exotic, and all of them are missing from a surprising share of production configs — usually not by decision, but because the config was copied from a tutorial years ago and nobody ever read it end to end. That reading is the audit.
Durability vs performance: the trade-off in two numbers
Two MySQL settings decide what a crash costs. innodb_flush_log_at_trx_commit = 0 tells InnoDB to flush the transaction log once a second instead of on every commit — fast, and up to a second of committed transactions vanish on a crash. The safe value is 1; 2 flushes to the operating system on every commit but only fsyncs once a second, so it survives a MySQL crash but not a power cut. sync_binlog = 0 is the same gamble for the binary log: without it, a crash can leave the binary log behind the data, and point-in-time recovery replays the wrong history.
Postgres makes the same trade with different names. wal_level = minimal disables the write-ahead log detail that replication and point-in-time recovery need, and archive_mode = off means old WAL segments are recycled instead of archived — so there is nothing to replay from. max_wal_senders = 0 blocks replicas from connecting at all. The pattern is the same on both sides: the fast setting is the default in some distributions, the safe setting costs a little throughput, and the cost of the fast one is only discovered during the incident it was supposed to protect against. The auditor flags each of these, and tells you which value to set.
MySQL vs Postgres: two config dialects
The two servers do not share a config language. A MySQL my.cnf is grouped by sections: [mysqld] holds server settings, [client] holds client defaults, and a setting only applies inside its section — the same key under a different header means something else. PostgreSQL’s postgresql.conf is a flat list of key = value lines, with quoted strings and # comments, no sections at all. Both support include directives — !include in MySQL, include in Postgres — and both are a trap for a static audit: the auditor notes them, but does not follow them, so an included file is a file you must audit separately.
The same intent also wears different names. MySQL’s bind-address is Postgres’s listen_addresses. MySQL’s innodb_buffer_pool_size is Postgres’s shared_buffers. Both have a max_connections, but the sane ceiling differs — Postgres forks a process per connection, so a few hundred is a lot, while MySQL threads handle more. The auditor detects the dialect from the content — a [mysqld] header or an innodb_ key means MySQL, shared_buffers or wal_level means Postgres — and applies the right rule set to each, so you can paste either file into the same page.
The five mistakes the auditor flags most
Across real-world configs, the same five findings recur. First, skip-grant-tables left in from a password-recovery session and never removed. Second, bind-address = 0.0.0.0 on a server that only ever serves localhost. Third, local-infile = ON — the default in some distributions, and an arbitrary-file-read hole. Fourth, innodb_flush_log_at_trx_commit = 0, usually copied from a benchmark-tuning post and never revisited. Fifth, encryption off or weak: ssl = off in Postgres, skip-ssl in MySQL, or password_encryption = md5 — the setting that makes every password in the database cheap to crack.
The demo config below manages most of them in 16 lines, plus a few extras: an empty secure-file-priv, general_log left on, binary logging off, statement-based replication, a latin1 character set, and a 64 MB buffer pool. The auditor scores it below 50 out of 100, band Poor. Its hardened twin — same shape, every finding fixed — scores 100.
What a static audit cannot see — and auditing yours in five minutes
A static audit reads text, and its limits are the limits of text. It cannot see the values the running server actually uses — a setting in the file can be overridden at startup, so check SHOW VARIABLES on MySQL or SHOW config_file and SHOW ALL on Postgres for the live truth. It cannot see total RAM, so a buffer pool it calls undersized may be exactly right for a small box. It cannot see replication lag, user privileges, or the authentication rules in Postgres’s pg_hba.conf — the file that decides who may connect, and with what method. And it cannot follow include directives, so an included file can undo a hardening setting the audit just praised.
To audit yours in five minutes: copy the config (or the one file you care about), paste it into the MySQL/Postgres Config Auditor — it runs entirely in your browser, and the config is never uploaded, which matters because a config names hosts, users and paths you do not publish. Fix the errors first (skip-grant-tables, SSL off, durability set to zero), then the warnings, then work through the infos as a list of defaults worth setting explicitly. Export the findings CSV if you want the checklist in a ticket. Then check the live values on the server — SHOW VARIABLES or SHOW ALL — and audit every file your main config includes, because a clean my.cnf can include a very broken one.
The broken demo config, excerpt
# Demo MySQL config — deliberately broken. Do not deploy.
!includedir /etc/mysql/conf.d
[mysqld]
datadir = /var/lib/mysql
skip-grant-tables
bind-address = 0.0.0.0
local-infile = ON
skip-ssl
require_secure_transport = OFF
default_authentication_plugin = mysql_native_password
general_log = ON
binlog_format = STATEMENT
innodb_flush_log_at_trx_commit = 0
sync_binlog = 0
max_connections = 2000
max_allowed_packet = 2G
sql_mode = NO_ENGINE_SUBSTITUTION
character-set-server = latin1
innodb_file_per_table = OFF