简体   繁体   中英

How to create a dump file when using mysqldump

I'm new to sql and trying to get to grips with some of the basics.

Say I've created a database as follows:

create database mydatabase;

and I want to back this up to a dump file. My confusion comes in here - what is this dump file? Does this automatically generate when I run the mysqldump command? Do I have to create it beforehand? If so, how? Sorry if this comes off stupid but I'm just lost here.

I know the final command would look as follows:

mysqldump -u -p mydatabase > SOMETHING ;

but I don't know what to actually insert as the something

The dump file is just a file usually with a bunch of scripts you can run to recreate something in the database. Different database system have their own way of generating these, but you could effectively take a dump from an mysql database and into another rdbms as long as the scripts are compatible.

There are different options;

  1. You could create a dump of just the schema. So that you can recreate that database later on without the data.

  2. Create the dump with schema and data. So that you can recreate the scheme as well as the data within it.

  3. Create the dump with just the data. So you can run those insert commands against another database of the same schema.

Basically dumps are just a way to get back to a previous state. They come in handy for different situation. Such as backing up data, replicating a data from one database to another.

As for the commands I have not used mysql in a while but looks like you are on the right track.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM