Database Reference
In-Depth Information
mysqldump -- user = ' russell ' - p \
rookery > rookery . sql
You should definitely do this, because having a backup of the rookery database will be
helpful in case you accidentally delete one of the tables or its data and then get confused
later when you're working on the exercises in later chapters. In fact, it's a good idea to
make a backup of the rookery database at the end of each chapter. Each dump file
should be named according to its chapter name (e.g.,rookery-ch1-end.sql,rookery-
ch2-end.sql, etc.) so that you can rewind to a specific point in the topic.
Later on, if you have a problem and need to restore thedatabase back to where you were
at the end of a chapter, you would enter something like the following from the command
line:
mysql -- user = ' russell ' - p \
rookery < rookery - ch2 - end . sql
Notice that this line does not use the mysqldump utility. We have to use the mysql client at
thecommand line to restore a dump file. When the dump file (rookery-ch2-end.sql) is
read into the database, it will delete the rookery database with its tables and data before
restoring the back up copy with its tables and data. Any data that users entered in the in-
terim into the rookery database will be lost. Notice that to restore from the dump file,
we're using a different redirect, the less-than sign ( < ) to tell mysql to take input from the
contents of the text file, rookery-ch2-end.sql . It's possible to restore only a table or to set
other limits on what is restored from a back up file. You can read about how to do that in
Chapter14 . Let's move on to learning the essentials of altering tables in MySQL and
MariaDB.
Search WWH ::




Custom Search