Landscape

Import a database using Drush

I have been using the same command snippet to import a database using drush for a long time:

`drush sql-connect` < ~/database.sql

Why fix what ain't broke, right? However, it did break when I recently switched from using the bash shell to fish. Fish does not support backticks, so this was an opportunity to update my old and outdated snippet while also improving it by prefixing it with a sql-drop command which removes everything from the database first.

drush sql-drop -y; drush sql-cli < ~/database.sql

Now shorter, and working in more shells!

Related Posts & Presentations