-2

I installed composer-Git and drush and was continuing with the installation of Drupal 8 from the command line. I read that you can create the database directly from drush, while in other parts I read that you must first create the database and then you can install the site from drush. I guess the answer can be create the database first but I prefer to be sure of what I can do with drush

The usage command is drush site-install --db-url = mysql://root:pass@localhost:port/dbname.

  • You create the database first with MySQL or whatever. And with that install command you tell Drush which database Drupal should use then. – leymannx Dec 28 '19 at 11:35
3

Drush will try to create the database if it doesn't exist. You can even provide an optional superuser account and password for the site-install command. Technically Drush doesn't create the database tables. The Drush site-install command runs the Drupal install procedure which does the job.

Reading core/INSTALL.mysql.txt you'll see that the normal procedure is to create the database first and then give the needed permissions on that databases. However, if you use a super user for you database (with the permission to create any database), Drupal will in fact also create the database when installing. This doesn't happen when you are using Drush.

|improve this answer|||||
  • Thanks to both for the reply. With phpMyAdmin I created the database and created a user with all privileges. then I ran the Drush dl drupal-8 --select command from git and downloaded me drupal without problems. I positioned myself in the folder where drupal is present and launched the command drush site-install --db-url = mysql: // user: pswd @ localhost: 80 / courses asks me if I want to create the courses database and answer yes but I get this error back You are about to CREATE the 'courses' database. Do you want to continue? (y / n): y Failed to create database: "mysql" is not recognized as – Gaetano Dec 29 '19 at 19:58
  • 1
    I have corrected my answer. Drush does in fact create the database. Anyway, your problem is that you miss the mysql-client package (which provides the mysql command). – hansfn Dec 30 '19 at 19:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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