Use Drush for generate a MySQL Database Dum File
Export Database to File
If you need to do it over and over again here are the commands for generate a dump of your current drupal project and working locally, I would say is necesary clear the drupal's cache before generate a dump file of your current database, unless you want to have the cache in your dump file.
Drupal 6 and 7
drush cc
drush sql-dump > ~/my-sql-dump-file-name.sql
Drupal 8
drush cr
drush sql-dump > ~/my-sql-dump-file-name.sql
Those two commands clear all the Drupal caches and then dump the sql database to a file in your home directory. Awesome sauce!
Download Database (optional)
If the sql dump file is on a remote server, you can use this terminal command to download a copy of the sql file:
scp tyler@example.com:~/my-sql-dump-file-name.sql ~/Desktop/
Import Database
You can use this command to import the sql dump back into your drupal database.
drush sql-drop
drush sql-cli < ~/my-sql-dump-file-name.sql
A Drush-Less Approach
If you don't have Drush setup (which you should have setup if you want to be cool), you can check out this article to make a backup copy of your Drupal's MySQL database from a terminal: Drupal - How to Make a Backup Copy of MySQL Database
Comentarios