Where Is the MySQL Data Directory?
MySQL stores every database as files under its data directory, /var/lib/mysql on Linux, with the path set by the datadir variable.
Last updated
Each database gets a subfolder in the data directory, while InnoDB keeps shared files like ibdata1 and the redo logs at the top level. Knowing this layout matters mostly for disk space triage and for planning moves.
Never copy these files while the server runs. InnoDB will happily hand you a corrupt snapshot. Routine backups belong to mysqldump or Percona XtraBackup. File copies are a migration method of last resort with the server stopped.
Where MySQL stores this, by platform
/var/lib/mysql
Confirm with SHOW VARIABLES LIKE 'datadir' in the mysql client. Server config lives at /etc/mysql/my.cnf with drop-ins under /etc/mysql/conf.d. MariaDB uses the same layout.
C:\ProgramData\MySQL\MySQL Server 8.0\Data
The version number in the path matches your install. ProgramData stays hidden until you enable hidden items in Explorer.
Frequently asked questions
How do I find the real datadir for sure?
Ask the server: SHOW VARIABLES LIKE 'datadir' prints the path it actually uses. Config files can disagree with reality after upgrades, and the running server wins.
Can I just copy the folder to back up?
Only with the server fully stopped, and even then restores are version sensitive. Scheduled mysqldump output is smaller, portable, and far less likely to betray you.
Notice an outdated path? Let us know.