All we need is an easy explanation of the problem, so here it is.
I’m using MariaDB 10.5, If I do the following:
"C:/Program Files (x86)/MariaDB 10.5/bin/mysqldump" --skip-comments --compact --lock-tables=false --add-drop-database --host=localhost --user=trainer --password=PASSWORD training > C:/Users/splatten/Documents/TrainerS1D5.sql
In the command I’ve specified training which is the database to export and it exports the tables, data and stored procedures from this database.
It looks like it should be working, but it doesn’t include either DROP DATABASE or CREATE DATABASE.
How to solve :
I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.
DROP DATABASE and
CREATE DATABASE commands are generally not part of a default dump operation. You will need to add one item to your command:
This will allow you to dump several databases if you wish, but you can also use this option if you would like to have
CREATE DATABASE and
USE inlaced in the output before each database is defined.
A note about
As one would expect, this option will add a
DROP DATABASE statement before each
CREATE DATABASE. This option is generally used alongside the
—databases options as there is no
CREATE DATABASE statements written without one of these options specified.
So, with this in mind, your command would look like this:
C:\Program Files (x86)\MariaDB 10.5\bin\mysqldump" --skip-comments --compact --lock-tables=false --add-drop-database --host=localhost --user=trainer --password=PASSWORD --databases training > C:\Users\splatten\Documents\TrainerS1D5.sql
Note: I’m not sure if the forward slashes you used in the command were intentional or not. I’ve replaced them with backslashes as Windows generally requires. Feel free to switch them back if this is in error.
Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂