Thursday, 9 July 2015

Faster MySQL drops and imports with Drush

Since moving to a local development model, I've been doing far more database imports. I'd been doing them through phpMyAdmin until a colleague showed me how much faster they were with Drush. It's a two-step process:
  • drush sql-drop - This drops the tables on your existing database.
  • drush sqlc < path/to/filename_here.sql - This imports the file into your database.

Notes

  • Both of these commands must be run inside the structure of your Drupal site. Be careful about where you run them -- if you're in the wrong site, you'll drop the wrong database. 
  • If you're having trouble remembering which carat to use, remember that the < pointing away from the file and toward sqlc means that the filename is being dropped into your database, not that the database is being exported to a file.
  • Remember to update the path to your database relative to where you're running the command. If you store your SQL file in sites/default/databases and you're running the command from inside sites/default/databases, just drush sqlc < filename_here.sql is plenty. If you were running it from, say, sites/all/themes, you'd need to add a path so Drush could find the file you were pointing to.
Ref: http://www.webbykat.com/2012/06/faster-mysql-drops-and-imports-drush

No comments:

Post a Comment

PHP Codesniffer - Ignore warning errors

 Use below command to ignore warnings while generating report. phpcs -n /path_to_directory/ The above command will result only errors and ig...