PHP Developer News

How to copy a Schema using MySQL Shell Dump & Load Utility ?

Another common question I receive about MySQL Shell Dump & Load Utility is how to dump a schema and load it with another name. Make a copy in fact.



Dumping the Schema



To do so, we need to use the dumpTables() method:



JS ? util.dumpTables("test", [], "/tmp/dump", {all: true})



It is important to notice that the second parameter is an empty array and the option “all” is enabled.



This will dump all tables of the test schena into /tmp/dump.



Loading the data into another Schema



Now, we will load the data we previously dump into another schema.



The first thing to do is to create the destination schema:



JS ? \sql create database test2



And finally, we load the data:



JS ? util.loadDump("/tmp/dump", {schema: "test2"})



Of course, you can always increase the parallelism using the threads option.



You can also load into another server.

Most Popular in Database