Where does MySQL/MariaDB store database data files on Linux or Unix?
By: +David Herron; Date: August 8, 2017
You launch the database server, give it a bunch of data to store, do you need to know where the data files are located? If MySQL or MariaDB does its job properly, the server just runs and runs with no need for further maintenance. But of course, software being software you need to do a bit more. For example, if the system crashes you might need to do a low-level recovery of the databases as I had to do - How to restore a MySQL database and tables from .frm .ibd or .myd raw database files
For various reasons you do need to know where MySQL/MariaDB stores its data files. It's not that hard to locate, and with a little change to the configuration file you can even change that location.
$ mysqladmin -u root -p variables | grep datadir Enter password: | datadir | /var/lib/mysql/ |
variables command lets you access all kinds of important status indicators from MySQL. It's worth your time exploring it further.
A similar approach is to
grep the information from the MySQL/MariaDB configuration file
$ grep datadirmy.cnf datadir= lib/mysql
The location for the configuration file on your machine may be different.
This file contains all the settings for your MySQL or MariaDB server. To change anything requires editing this file and then restarting the server.
For more information, see: https://dev.mysql.com/doc/refman/5.7/en/option-files.html