A 'partial' Answer...
The .frm
contains, in an encoded format, the CREATE TABLE
for the one table.
Copying a .frm
into your copy of MySQL would, in theory, give you the schema definition. But, other info is needed. So, now the challenge is to try to re-establish a table where the data is lost, but the schema is still in the .frm. MyISAM depends on the existence of a .MYD
(.MYI
can be reconstructed); InnoDB has some hooks in ibdata1
, but these may be reconstructable. (Hence, this Answer is only 'partial'.)
.frm
files are probably binary compatible between OS versions, even big-endian vs little-endian. And across large swaths of MySQL/MariaDB versions. A table with a JSON
column would not be backward compatible. There have been only a few other incompatible changes in the past decade.
As for hacking into your system. Which is easier to get into -- The filesystem, or MySQL? The .frm file is somewhat protected by directory and file permissions. MySQL is somewhat protected by its password mechanism. Obviously, you should do whatever you can to prevent access to both.
A common entry point into MySQL is via web arguments (<form>s
in HTML) where the values are not properly escaped before INSERTing
text into the database. There are different solutions to that entrypoint, depending on which API is used. (I've seem a hacker post /etc/passwd
on the Internet; he got it from a PHP program that failed to escape simple data entry fields.) See "SQL Injection".
Is your schema the most valuable thing? I would expect the data to be more important. And also the root
password for your server.