You are here

Export Database to File

So today I wanted to learn how to export a Drupal database to a file quickly. Back in the day I would've logged in through cPanel and navigated to PHPMyAdmin, then manually select an export of the database and have to choose where to save the file. Not to mention all the previous steps listed would need to be preceeded by a Drupal cache flush (I don't like the cache inside a database backup). Typically this would've taken me about 5 minutes to complete, well my friends, no longer is that the case. Behold the power of Drush (once you are ssh'd in and navigated to your drupal root directory)

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

 

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.
Lorenzo (not verified) - Sun, 04/09/2017 - 07:00

Good site you have here.. It's difficult to find high quality writing like yours nowadays.
I truly appreciate people like you! Take care!!

my blog post :: manicure

Mohammad (not verified) - Thu, 05/04/2017 - 02:36

Sweet blog! I found it while searching on Yahoo News.
Do you have any suggestions on how to get listed in Yahoo
News? I've been trying for a while but I never seem
to get there! Cheers

Also visit my web-site - uric acid levels
(eleaselibert.wordpress.com)

Janine (not verified) - Wed, 08/09/2017 - 19:55

cialis how to buy

cialis pills

cialis tabletas for sale

Phoebe (not verified) - Thu, 08/10/2017 - 14:16

cialis sale

tadalafil generic

buy cialis online generic

Sean (not verified) - Fri, 08/25/2017 - 04:22

cialis for sale online in canada

cialis 10 mg

cheapest cialis au

Latasha (not verified) - Tue, 09/12/2017 - 16:13

t observe comprar cialis original online law cialis online

j differently can you chew cialis encounter [url=http://hqcialismog.com/]buy generic cialis[/url] cialis sante az resolve

Jacquelyn (not verified) - Tue, 09/12/2017 - 18:25

y check how long does a dose of cialis last involvement generic cialis

q shut cialis e extrasistole award [url=http://hqcialismog.com/]Cialis generic[/url] superman pills viagra cialis visitor

Pages