SQLNirvana by Pyro

Blog › mysql · security

MySQL security checklist: 10 things to check today

Ten quick checks that close the most common holes in MySQL servers: accounts, network exposure, TLS and a few risky defaults.

Most MySQL security problems aren't exotic. They're accounts nobody remembers creating, servers listening on every network, and old defaults nobody changed. These ten checks take a few minutes each.

Accounts

1. No anonymous accounts. Old installs created users with an empty name.

SELECT user, host FROM mysql.user WHERE user = '';

2. No accounts without a password. Socket-authenticated accounts (auth_socket) are fine; others with an empty password are not.

SELECT user, host, plugin FROM mysql.user WHERE authentication_string = '' AND plugin NOT IN ('auth_socket', 'unix_socket');

3. root only from localhost. Use named admin accounts for remote administration.

SELECT user, host FROM mysql.user WHERE user = 'root' AND host NOT IN ('localhost', '127.0.0.1', '::1');

4. No powerful accounts reachable from anywhere. An account with global privileges and host % can administer the server from any network that reaches it.

SELECT user, host FROM mysql.user WHERE host = '%' AND (Super_priv = 'Y' OR Grant_priv = 'Y');

5. Application accounts get only what they need. Usually SELECT, INSERT, UPDATE, DELETE on one schema. Not ALL ON ..

Authentication

6. Move off mysql_native_password. It uses SHA-1, is deprecated, and is disabled by default in MySQL 8.4. Use caching_sha2_password.

7. Enforce strong passwords. Install the password validation component:

INSTALL COMPONENT 'file://component_validate_password';

Network

8. Listen only where you need to. bind_address set to * or 0.0.0.0 exposes MySQL on every interface. Bind to a private address and firewall port 3306 to the hosts that need it.

9. Require encrypted connections. MySQL 8 creates certificates automatically, so turning on TLS is mostly a setting:

SET PERSIST require_secure_transport = ON;
SET PERSIST tls_version = 'TLSv1.2,TLSv1.3';

Check that every client supports TLS before flipping require_secure_transport.

Risky features

10. Turn off local_infile unless you use LOAD DATA LOCAL. It lets a client read files from the machine it runs on, which a compromised or malicious server can abuse.

SET PERSIST local_infile = OFF;

And keep it current

Run a supported version: MySQL 8.0 stopped receiving security fixes in April 2026. See what to do about MySQL 8.0 end of life.

SQLNirvana runs these checks, and a few more, on every server once a minute, with the fix for each failure. The free MySQL health check runs them once.

Let SQLNirvana watch it for you

Health, tuning, security and upgrade checks every minute. Free for one server.

Start free