Installing Drupal 7 from scratch using Drush

Drush is awesome. If you haven't already installed Drush check It's pretty easy to setup, just download, create an alias for it, then run and go.

One of the great features of Drush for Drupal 7 is you can do a brand new site install with two simple commands. First setup a MySQL user and database, and note the user/pass.

Then run the following, making sure to replace the user and passwords names for your local setup:

drush dl drupal-7.x
drush site-install standard --account-name=admin --account-pass=admin --db-url=mysql://YourMySQLUser:RandomPassword@localhost/YourMySQLDatabase

And boom, the script runs and you're done.

*Note: The Drupal username and password seemed to always end up as admin/admin no matter what I set them to. So, I suggest just using those and then changing them after you login to your new site.


Drush Make and install profiles

You can go a few steps further to make your life really easy.

Check out Drush Make to automate the installation of modules, themes, patches and javascript libraries.

And create a custom profile in the /profiles folder to configure the site to your preference. This saves a lot of clicking in the interface.

On my development environment

On my development environment, drush dl drupal-7.x downloads the dev version of Drupal 7. Is there a command that will force the download of the most recent version of Drupal 7?

Yes, actually if you just

Yes, actually if you just shorten it to : drush dl drupal
Then you will get the latest stable version.

Also, if you know the version number you are looking for, such as 7.2, then you can do drush dl drupal-7.2

Another option

If you know you want a Drupal 6 install, for whatever reason, you can type:

drush dl drupal-6

and it will use the recommended (or latest) release of that version. As Caulfield said earlier, you can enter:

drush dl drupal

and it will get the generally recommended release, or at the moment Drupal-7.15.

Just worked it out for myself

Just worked it out for myself: drush dl drupal-7.2 :)

Oh awesome, hehe I replied

Oh awesome, hehe I replied before realized you had already figured it out :)


You saved a good deal of reading, thanks! My mistake? Running the command BEFORE setting up the virtual host on my MAMP instance (so, naturally, drush said; "what?")

Drupal and Drush!

I am using this script to automatically create accounts! Thanks a TON!

This does NOT work!

I try this command.

drush site-install standard --account-name=garry --account-pass=SomePassword --db-url=mysql://SomeUser:SomePassword@localhost

and it does NOT work. It fails with Event Not found. What is going on here?!?

If you have bang symbol (!)

If you have bang symbol (!) in your password, then this will fail, drush/command line can't handle a bang symbol, and I'm guessing that is what your problem is.

! has a special meaning in

! has a special meaning in bash, so if you want to use it as a part of a password, you have to quote (with single quote!) your password.

clean url's was enabled by

clean url's was enabled by drush, but not working and throwing errors.

User1 username/password

User1 username/password defaults to admin/admin with Drush site-install so if you're happy with that setup you could simplify it even further by not bothering to specify them. Also 'site-install' is accessible via the alias 'si'.

So, an even shorter version that does the same thing:

drush si standard --db-url=mysql://[dbuser]:[dbpass]@localhost/[dbname]

Actually, scratch that last

Actually, scratch that last comment. Drush tells you what the username/password is if you don't specify them (username will always be 'admin') once it's completed the install.

Missing step/option

One thing that got me with this is that you need to CD into the Drupal install directory created by "drush dl drupal-7"
I'm guessing you can also specify the installation directory with an option for the "drush site-install" command.

Drush Make

I've checked out Check out <a href="">Drush Make</a> to automate the installation of modules, themes, and other resources. It is really great - thanks for the info.

I had to manually add the .htaccess

Thanks for the tip, I used the drush command "drush dl drupal" but it did not download the .htaccess. so after the installation, I could reach the home page but it gave me a 404 error page. When i checked my Drupal install (7.22 at that time), the .htaccess was missing so i understood... easy to fix by downloading it and adding it via ftp...

Bootstrap Level


When entering either

drush si standard --db-url=mysql://root:root@localhost/DB_LOCAL2


drush site-install standard --account-name=admin --account-pass=admin --db-url=mysql://root:root@localhost/DB_LOCAL2

I get the following error message:

site-install needs a higher bootstrap level to run - you [error]
will need invoke drush from a more functional Drupal environment to
run this command

What does this mean, and how can I fix this?

Add new comment

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Comment using an existing account (Google, Twitter, etc.)