Where is MySQL / MariaDB storage location by default on CentOS 7?

Where is MySQL / MariaDB storage location by default on CentOS 7? No special configuration to the MariaDB from official repository of CentOS.

On CentOS 7 Linux it is usually by default

/var/lib/mysql

But here I give you another “hacky” way to find it out.

The method is to find out the mysql daemon mysqld’ opened files and the paths because it must open the files to read/write data.

First, find out the process ID of the mysqld process:

# ps aux | grep mysqld

mysql    25403  1.0 17.2 1322220 174948 ?      Ssl  Aug31 178:10 /usr/sbin/mysqld

Second, go to the mysqld process’ dir under /proc/. For the above example,

# cd /proc/25403/

Check the opened files under the directory fd:

# ls fd -lha

An example is as follows for some files:

lrwx------. 1 mysql mysql 64 Sep 12 11:43 83 -> /var/lib/mysql/my_wp2/wp_links.MYI
lrwx------. 1 mysql mysql 64 Sep 12 11:43 84 -> /var/lib/mysql/my_wp2/wp_links.MYD

You get the path for the directory to storing the database data files.

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *