Use Drush to Export/import a Drupal MySQL Database Dump File

Source: Internet
Author: User
Tags drupal drupal cache import database

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.