0

How come when I write the following line in my CMD:

mysqldump -hHOST -uAdmin -p TestDatabase --single-transaction --routines --triggers > "C:\testdump_backup\testdump.sql"

Then the file has this in it

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `TestDatabase ` /*!40100 DEFAULT CHARACTER SET latin1 */;

USE `TestDatabase`;

This is a problem for me, when I want to load all this to another database called Database_production like this:

mysql -hHOST -uAdmin -p Database_production < "C:\testdump_backup\testdump.sql"

It all works if I just use the following mysqldump line:

mysqldump -hHOST -uAdmin -p TestDatabase > "C:\testdump_backup\testdump.sql"

The only problem is that this doesn't contain my stored_procedures and function, which I need.

With the above line the file doesn't have that part with USE TestDatabase;, but which of the --.. adds this part?

I need to mysqldump to copy tables/stored_procedures/functions, thats why I used --single-transaction --routines --triggers, but what am I missing here, do I even need the --... or?

1
  • @basha04 This works, do you actually know, if I make a extra column/table/prodecure/functions in the database I'm importing and then export the mysqldumped database into this, if it would fail/remove/overwrite the things being worked on on the "test database"
    – Mads
    Commented Sep 2, 2021 at 7:24

1 Answer 1

0

See the options (on mysqldump):

--skip-create-options

--no-create-db
2
  • do you know, if I make a extra column/table/prodecure/functions in the database I'm importing and then export the mysqldumped database into this, if it would fail/remove/overwrite the things being worked on on the "test database"
    – Mads
    Commented Sep 2, 2021 at 7:25
  • @Mads - Look in the dump file (it is readable); search for DROP. Or search for where the item is being CREATEd; there might not be a DROP shortly before it. Then check the options to mysqldump relating to DROP.
    – Rick James
    Commented Sep 2, 2021 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.