27
loading...
This website collects cookies to deliver better user experience
mysqldump -u username -p database_name > db_dump.sql
mysqldump
does not show a success message. Do ls
in the directory where you ran the command to find DB-dump.sql
. You can include or exclude specific content into a dump and have the gzipped compression. For details visit MySQL dump: Database backup program resources.scp
to move database backup.scp user@oldhost:/home/user/db_dump.sql user@newhost:/home/user
mysqlimport -u username -p database_name < db_dump.sql
mysql> use database_name;
mysql > source db_dump.sql
mysql -u username -p database_name < db_dump.sql
mysqldump
inside the MySQL console. The mysqldump
is not a MySQL command. It is a separate program to be run in a Linux shell.mysqldump
is convenient and flexible as you can view and edit the output before restoring. However, restoring data can be slow because executing SQL statements involves disk I/O operations. The best use cases for mysqldump are small sites, WordPress blog database or during the development phase of a project. For large-scale databases using physical backup and restore is more appropriate.mysqldump --opt db_name | mysql --host=remote_host -C db_name
--opt
Enabled by default, --opt
is shorthand for --add-drop-table --add-locks --create-options --disable-keys --extended-insert --lock-tables --quick --set-charset--skip-add-locks
Do not add locks--skip-opt
Turn off options set by --opt
--verbose
Verbose mode--where
Dump only rows selected by given WHERE condition--xml
Produce XML output--tables
add table name arguments following the option to dump only those tables--ignore-table
exclude tables from dump --ignore-table=db_name.tbl_name
--no-data, -d
dump only the CREATE TABLE statement for the table