So-today I wanted to learn-to-export a Drupal database to a file quickly. Back on the day I would ' ve logged in through CPanel and navigated to PHPMyAdmin, then manually select an export of the DAT Abase and has to choose where to save the file. Not to mention all the previous steps listed would need to being preceeded by a Drupal cache flush (I don't like the cache in Side a database backup). Typically this would ' ve taken me on 5 minutes to complete, well my friends, no longer are the case. Behold the power of drush (once you is SSH ' d in and navigated to your Drupal root directory)
Drush Ccdrush sql-dump > ~/my-sql-dump-file-name.sql
Those commands clear all the Drupal caches and then dumps 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 [Email Protected]:~/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-dropdrush Sql-cli < ~/my-sql-dump-file-name.sql
A drush-less Approach
If you don't have Drush setup (which you should has setup if you want to being 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
Use Drush to Export/import a Drupal MySQL Database Dump File