I have a MySQL database with tables in the form of "shard_0"
, "shard_1
", "shard_2"
, etc.
These are virtual shards. Now I want to add another DB server and move the even-numbered shards ("shard_0"
, "shard_2"
, "shard_4"
, ...) to the new machine.
What is the best way to do that? There are many tables so ideally I wouldn't have to type out each table name individually but do something automatically. Perhaps something like:
# pseudo code
for i in range(n):
tablename = "shard_"+str(2*i)
# Move tablename to new machine
Thanks