Captain
Captain

Reputation: 5087

when moving mysql database files location,do I need to flush table?

Im going to move database files location (including changing datadir in my.cnf).

but I still not clear about FLUSH TABLES;

mysql website says: "clears or reloads various internal caches used by MySQL"

some people says: "forcing all open tables (those in the table cache) to be closed"

what is open and close tables? do I need to flush table when move database files location ?

Upvotes: 0

Views: 187

Answers (2)

Itay Moav -Malimovka
Itay Moav -Malimovka

Reputation: 53607

The safest is to simply shut down the server, move the files, turn it on.
Tables can have locks on them (read and/or write), a query can be touching some of the tables in the DB, The tables caches it's cardinality (how unique is the field value) and the number of records in it for example...

Upvotes: 1

Eric Petroelje
Eric Petroelje

Reputation: 60528

Any data that needs to be flushed should be flushed when the server shuts down, and you'll need to shut down the server anyways for the config changes to work, so here's what I would do:

  1. Shut down MySQL.
  2. Move the files to the new location.
  3. Change the datadir in the config file.
  4. Restart the server.

Upvotes: 3

Related Questions