Why is MySQL database data-files deployed under /var/lib/mysql?
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/&lt;user&gt; 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).