Default Port: 3306
MySQL is the most common open-source database backend behind web applications, which means it shows up constantly and often holds the actual data an engagement is after. A low-privilege account gets you data; an account with FILE privilege can read and write files on the underlying server, which turns a database compromise into a full host compromise.
Standard Access
A valid login without elevated privileges. Enough to enumerate databases, tables, and whatever data the account can
SELECT.FILE Privilege
Lets the account read arbitrary files with
LOAD_FILE() and write them with INTO OUTFILE, the basis for webshell drops and, combined with UDFs, full RCE.Connecting
Recon
mysql client installed:
Enumeration
Once connected, these cover the standard recon pass: what version is running, what databases exist, and what the current account can actually do.Privilege and configuration enumeration
Privilege and configuration enumeration
Checking privileges tells you whether file read/write and RCE paths are even worth attempting before you try them.An empty
secure_file_priv value means no restriction at all; a specific path restricts file operations to that directory; NULL disables file operations entirely.Brute Forcing
Metasploit Modules
File Read and Write
Both of these require the
FILE privilege, and are blocked outright if secure_file_priv is set to a restrictive path. Check it first (see the Accordion above) before assuming either is possible.UDF-Based Remote Code Execution
User Defined Functions let MySQL call out to a compiled shared library. If you can write that library into the plugin directory (viaINTO OUTFILE or INTO DUMPFILE) and the FILE privilege allows it, you can register a function that runs arbitrary OS commands.
Raptor UDF exploit walkthrough (classic Linux technique)
Raptor UDF exploit walkthrough (classic Linux technique)
Hash Extraction and Cracking
Privilege Escalation and Persistence
With sufficient privileges, creating a standing admin account is faster than repeatedly using a found credential, though it’s a noisy, high-impact action.Credential Harvesting from the Host
If you’ve already got OS-level access (or RCE through a UDF), these files commonly leak MySQL credentials directly rather than needing to crack anything.Quick Reference Tools
Hackviser: MySQL
Quick-reference pentesting guide for the MySQL service.
HackTricks: MySQL
Deeper breakdown of MySQL enumeration and exploitation techniques.

