MySQL / MariaDB: find the data directory and data files
Queries to locate the data directory and tablespace files of MySQL or MariaDB.
To find where MySQL or MariaDB stores its data files, query the server variables.
SHOW VARIABLES LIKE 'datadir';
SELECT @@datadir;
SHOW VARIABLES LIKE 'innodb_data%';
SHOW VARIABLES LIKE 'innodb_file_per_table';
datadir: root data directory (one subdirectory per database).innodb_data_home_dirandinnodb_data_file_path: location and definition of the InnoDB system tablespace files.innodb_file_per_table: whenON, each InnoDB table has its own.ibdfile.
On MySQL, the INFORMATION_SCHEMA.FILES view lists the tablespace files:
SELECT FILE_NAME, TABLESPACE_NAME FROM INFORMATION_SCHEMA.FILES;
Source: Check data file location and tablespaces in MariaDB or MySQL.