How to automatically move specific MySQL tables from one machine to another?
I have a MySQL database with tables in the form of
These are virtual shards. Now I want to add another DB server and move the even-numbered shards (
"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
I'd create a single (or perhaps multiple) mysqldump invocations, like so
print "mysqldump database", for i in range(n): print "shard_"+str(2*i),
Run this command in a shell, and move the dump file to the new machine, then run it there through mysql. Then generate and run the "drop table" statements for the tables you have moved.
- A Linux, Apache, MySQL, PHP (LAMP) stack is a combination of open source software that is typically installed together to enable a server to host dynamic […]
- MySQL is an the most popular open-source database management system, in most of hosting company its has been bundle by LAMP(Linux, Apache, MySQL, PHP/Python/Perl) stack. Another alternative […]
- MySQL is the world’s most popular open-source database. Despite its powerful features, MySQL is simple to set up and easy to use. Below are some instructions […]