Trying to install Drupal 8 using drush.

drush dl drupal --drupal-project-rename=example
cd example

So far, so good.

However, when I get to this part:

drush site-install standard --db-url='mysql://root:my+Password@localhost/db_name' --site-name=Example

I've also tried:

drush site-install standard --db-url='mysql://root:[email protected]/db_name' --site-name=Example

But I get the following error:

Failed to connect to your database server. The server reports the following message: SQLSTATE[HY000] [1045] Access denied for user root@localhost (using password: YES) Is the database server running? Does the database exist or does the database user have sufficient privileges to create the database? Have you entered the correct database name? Have you entered the correct username and password? Have you entered the correct database hostname?

All of the answers are "Yes," so the install should work. Is it something wrong with my syntax? I have other Drupal sites on this server that I've installed manually, it's just the Drush install I can't get to work. What am I doing wrong?


3 Answers 3


It is probably because you do not have a setting for the super user (user/1). You need to set the account user name and password, so you can login to Drupal.

drush site-install standard --account-name=admin --account-pass=12345 --db-url=mysql://dbusername:dbpass@localhost/db_name --site-name=Example
  • Tried your suggestion and got the same error. My MySQL password has a special character, + (plus sign). I think Drush isn't escaping it properly.
    – GTS Joe
    Jul 5, 2016 at 5:41
  • @GTSJoe maybe try it without the --site-name=Example part, else change your pass or create a new db user with a simple pass to test your theory.
    – No Sssweat
    Jul 5, 2016 at 8:18

In your command you have not mentioned the mysql port. Please refer the following command.

drush si --db-url=mysql://db-user:db-pass@localhost:3306/db-name

Username and Password is optional, once the site is installed the auto-generated username and password will be provided on the console. Please note it carefully.


This one was tricky but I finally figured it out myself. The reason the installation was failing was because my MySQL password had special characters. Drush can't escape special characters, so I had to change the password using the following command:

mysqladmin -uroot -pOldPassword password newPassword

After that, it worked like a charm!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.