I am using mysqldump to backup a database containing several tables (say tables D, E, F). I use the following command: mysqldump -uuser -ppassword SourceDatabase > file.sql to backup these tables.
I would like to know if I restored this backup, would it overwrite other tables? For example, if I have a database DestinationDatabase, containing tables A, B and C, and after running the command "mysql -uuser -ppassword DestinationDatabase < file.sql", would I lose the tables A, B and C on the destination database (and be left with just D, E and F) or would I be left with A, B, C, D, E and F (with the original tables present in DestinationDatabase left untouched)?
Thanks in advance, Tim
In this tutorial, we present two easy ways to back up and restore your MySQL Database. The mysqldump client utility can dump a database including the SQL statements required to rebuild the database. By default, the dump file includes the SQL commands to restore the tables and data. To back up your MySQL database, the general syntax is:
To backup multiple tables using mysqldump, enter the table names separated by a space after the database name. For example, this command will backup both the author and book tables in the gravity_books database. mysqldump -u root -p gravity_books author book > db_gravity_author_book.sql The SQL file generated contains the commands for both tables.
Restoring an SQL dump file using the SOURCE command. To restore the mydb.sql SQL dump file, you follow these steps: First, connect to MySQL server: C:>mysql -u root -p Enter password: ********. Second, drop the mydb database: mysql> drop database mydb; Third, use the SOURCE command to load the dump file: mysql>source c: backup mydb.sql.
The mysqldump utility is a command-line tool that comes with the MySQL databaseand lets you backup and restore your database. It produces SQL files that can be used to restore the database. You can use it to backup one or more databases, or backup tables within a database.
With the default options, it will not delete tables A
, B
and C
. It will however overwrite (delete current data that is not in the backup) tables D
, E
and F
.
To see the list of available options see here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With