How does MySQL still function even though I move .ibd file to arbitrary places? I have a table Person. AFAIU, the data for this table is stored in /usr/local/mysql/data/my_database/person.ibd.

Now, I make an insert. Then I check out the contents of person.ibd with vim. The data I have just entered is indeed there.

Then, I move the person.ibd to my home directory. I again make an insert and check out the contents of person.ibd with vim. The new data is inserted into the file even though the file is now in my home directory, instead of being at /usr/local/mysql/data/my_database/person.ibd.

I repeat this action by moving the person.ibd to various other places, such as to /etc/. The new data is always inserted.

So, what's going on? How does this happen? Does MySQL search the whole file system before writing the insert to a file in the file system?

Furthermore:

I open the person.ibd with vim and edit a varchar type field of a record and save the file. Then I run a select but MySQL sees the old data. I exit from MySQL and enter again, but MySQL still sees the old data even though that data does not exist anymore in person.ibd and it is replaced by the new content which I have edited into the person.ibd file using vim.

So again, what's going on?
Do NOT edit a .ibd file!  Things are likely to go wrong:


The layout of the file is complex, and you are likely to make it unreadable by MySQL.
The data is probably cached in RAM, so your changes are not immediately recognized and/or they will be overwritten when MySQL decides to rewrite the 16KB block you modified.
There could be a block split, further rendering your edits a mess.


As for "Moving" a file, let me give you a basic lesson in the *nix filesystem.  A file is (in simplistic terms) two things:  A chunk of data sitting somewhere on disk, and a directory entry pointing to that chunk of data.  When a "file" is "opened" (which MySQL did long ago), it grabs the pointer to the chunk of data, but does not look at the directory entry again.  You did mv, which only removes one directory entry and creates a new entry.  This new entry points to the same chunk of data on disk.

So, until, MySQL closes the file, it still has the file, regardless of what path(s) it is known by.

Note that that explains how "hard" links can work trivially.  A second reference (hard link) to the same file is simply a different directory entry pointing to the same chunk of data.

Please study the structure of *nix filesystem.  Your incomplete knowledge is rapidly propelling you into disaster!

By the way, if you leave the .ibd in its new location. MySQL won't find it after it restarts.  You will have "lost" that table, and have a repair situation that could be baffling.