Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
docs:mysql:mysqldump [2007/08/09 13:25] – billh | docs:mysql:mysqldump [2008/08/03 00:25] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 10: | Line 10: | ||
===== examples ===== | ===== examples ===== | ||
+ | My example...adds create database statements too so the only thing you need to do is source the file to restore | ||
+ | < | ||
+ | mysqldump -u user -p --opt --databases " | ||
+ | </ | ||
+ | |||
The most normal use of mysqldump is probably for making a backup of whole databases. | The most normal use of mysqldump is probably for making a backup of whole databases. | ||
< | < | ||
- | mysqldump --opt database > backup-file.sql | + | shell> |
Note: --opt is the same as: --add-drop-table --add-locks --all --extended-insert --quick --lock-tables | Note: --opt is the same as: --add-drop-table --add-locks --all --extended-insert --quick --lock-tables | ||
Line 20: | Line 25: | ||
Most likely, you will need to provide user credentials: | Most likely, you will need to provide user credentials: | ||
< | < | ||
- | mysqldump --opt -u user -p database > backup-file.sql | + | shell> |
</ | </ | ||
- | |||
You can read this back into MySQL with: | You can read this back into MySQL with: | ||
< | < | ||
- | mysql database < backup-file.sql | + | shell> |
or | or | ||
- | mysql -e ' | + | shell> |
+ | |||
+ | or | ||
+ | |||
+ | mysql> source / | ||
+ | |||
+ | or, most likely... | ||
+ | |||
+ | mysql> create database databasename; | ||
+ | mysql> use databasename; | ||
+ | mysql> source / | ||
+ | |||
+ | * the source command can be followed with a path containing spaces, without escapes or quotes | ||
</ | </ | ||