Where Is the MySQL Data Directory?
MySQL datadir defaults on Windows, macOS and Linux, and the @@datadir query that prints the live path.
Last updated
MySQL stores databases as files under a data directory that varies by OS and install method. The version number sits in the Windows path, so it shifts every major upgrade.
Do not trust guides over the server itself. Query the datadir variable and it prints the path your running instance actually uses.
Where MySQL stores this, by platform
C:\ProgramData\MySQL\MySQL Server 8.0\Data
Version in the path changes per release. ProgramData stays hidden; paste the path into the File Explorer address bar. Stop the service before copying files.
/usr/local/mysql/data
DMG install default. Homebrew builds use their Cellar plus data dir instead; check the running config when in doubt.
/var/lib/mysql
Standard across Debian and RHEL families. The mysql user owns it; back up with mysqldump rather than raw file copy on live servers.
Frequently asked questions
How do I print the real data directory?
Ask the server for its datadir variable. That beats any documented default when installers customized the path.
Can I just copy the Data folder as backup?
Only with the server stopped, and restores demand matching versions. Logical dumps restore across versions far more safely.
Notice an outdated path? Let us know.