I was wondering why do we deploy data files under /var/lib/mysql/. Is there a logical reason for that, or is that just a "traditional" place for the data?

I will value more answers based on standards like the LSB or the POSIX, and would appreciate links to the policies of your favourite Linux or Unix implementation that dictate this is the expected place to deploy your data.

Many thanks in advance for your attention and answers.

Kind regards,

-- LMC


In the Filesystem Hierarchy Standard, /var/lib is listed as containing:

State information. Persistent data modified by programs as they run, e.g., databases, packaging system metadata, etc.

So it is very much because it is the traditional/documented place to put such things. If a database system or similar is installed under /opt it is common for the data files to also be under /opt, though many would argue that /var/lib is still the right default location in that case (with state pertaining to the running of the app in /opt and state/data produced or consumed by the app (such as user databases) under /var/lib).

Of course on a multi-user system, keeping user databases under /home/<user> often makes more sense, though not all database engines support this (or don't support it easily, without some manual jiggery-pokery on the part of your SysAdmin/DBA).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.