What to know
- Inventory sockets, local TCP and remote database clients.
- Inspect grants using the actual application account.
- Test a scoped replacement before retiring existing access.
Map every legitimate database client
This guide covers a MariaDB server you administer. List the web application, workers, backup jobs, monitoring and any remote reporting systems before changing access. Record whether each uses a Unix socket, loopback or a private network address. Keep an administrator connection and a consistent backup available. A listener change can interrupt applications even when the website and database share one machine.
Inspect the listener and account context
Use an authorized MariaDB session to inspect these values. The network guide explains bind-address and skip-networking.
SHOW VARIABLES LIKE 'bind_address';
SHOW VARIABLES LIKE 'port';
SELECT USER(), CURRENT_USER();Compare the result with sudo ss -lntp on the host. A loopback bind may suit a same-host TCP client, but not an application connecting from a separate container or server. For remote clients, plan a private interface, restricted source rules and verified TLS configuration for your installed client and server versions.
Review the application’s real privileges
Run the following as the application account, not as the administrator, to see its own grants. The SHOW GRANTS reference describes the output.
SHOW GRANTS;Do not publish the output because account details or authentication data can be sensitive. Separate runtime permissions from the account used to deploy schema migrations. Avoid using the database root account as the website login.
Build a scoped replacement in staging
For an already-created example account, the GRANT syntax allows a narrowly scoped policy:
GRANT SELECT, INSERT, UPDATE, DELETE
ON appdb.* TO 'webapp'@'localhost';Replace the database, account and host with your actual design. This is a simple CRUD example; some applications need additional reviewed permissions. Create credentials through your protected administration workflow. Test normal requests, workers and backups before retiring the previous account.
Apply and prove the boundary
Schedule listener changes with a rollback configuration ready. Confirm every approved client still connects and an unauthorized external client cannot. Recheck both address families and provider firewalls. Keep migration tests separate from runtime tests so permissions are not expanded casually to make one deployment succeed. Our Docker network guide and credential management guide cover the neighboring controls.
Sources & further reading
Primary sources supporting this article. The practical recommendations are Kiava’s general guidance and should be adapted to your project.
