I want to use mysqlsh to do the following:
- Dump the FULL schema of a given database (not just tables, but functions, triggers, everything related to this database schema, same as
mysqldump -R DATABASE > DATABASE.sql
) - Load this full schema into a brand new database I just created (similar to
mysql --database=NEWDATABASE < DATABASE.sql
)
When I run mysqlsh --execute 'util.dumpTables("DATABASE", [], "SQL/DATABASE", {all:true});'
, it of course just dumps the tables, and this can easily be imported into a brand new database with this command mysqlsh --database=NEWDATABASE --execute 'util.loadDump("SQL/DATABASE", {schema: 'NEWDATABASE', ignoreVersion:true,resetProgress:true});
. The problem is it is missing the functions and stored procedures.
So then I tried mysqlsh --execute 'util.dumpSchemas(["DATABASE"], "DATABASE");'
, and then load it into a new DB with mysqlsh --database=NEWDATABASE --execute 'util.loadDump("DATABASE", {dryRun: true, ignoreVersion:true});'
, but I instantly notice that it is trying to load into the original database, not my new database. So how do I load it into a NEW database, one with a totally different name?
In case you are wondering, I am trying to learn how to maximize mysqlsh for my use case. So the old mysqldump
is not an option in this case.