Answers.Body: <p>After doing some print-line debugging, I traced the issue to <a href="https://github.com/civicrm/civicrm-drupal/blob/7.x-master/drush/civicrm.drush.inc#L413" rel="nofollow">line 413</a> which determines whether or not pre-generated demo data should be loaded.</p>
  
  <p>I have tried a variety of combinations to no avail:
  <code>
  load_generated_data=false
  load_generated_data=FALSE
  load_generated_data="FALSE"
  </code></p>
  
  <p>As I am out of ideas, for now the flag is just going to be removed from my script. However, it appears that this is a bug with the Drush command.</p>
  
  <p>Thanks to everyone who took a look and offered advice, here and on IRC.</p>
  
  <p><strong>Edit:</strong> load_generated_data=0 WORKS!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-30T01:10:03.787Z
Answers.Text: Did you try `--load-generated-data=0`? Most strings, including "false", evaluate to true: `php -r "if ('false') print 'yes';" // => 'yes'`
Answers.UserDisplayName: Chris Burgess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-28T16:45:34.287Z
Answers.LastActivityDate: 2016-03-30T14:43:12.433Z
Answers.LastEditDate: 2016-03-30T14:43:12.433Z
Answers.UserDisplayName: Salt
Answers.Body: <p>This error can happen if you attempt to load a CiviCRM DB over the top of an existing DB. It's possible that's what you're running into here.</p>
  
  <p>Looks like there are two files in the CiviCRM distribution which might try to populate that table, so make sure you aren't getting both executed.</p>
  
  <ul>
  <li><code>civicrm/sql/civicrm_acl.mysql</code></li>
  <li><code>civicrm/sql/civicrm_generated.mysql</code></li>
  </ul>
  
  <p>But this is speculative - can you describe in detail how you're installing CiviCRM via Drush? That might help someone reproduce the error you're hitting or give a more definite reply.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-28T04:21:37.423Z
Answers.LastActivityDate: 2016-03-28T04:21:37.423Z
Answers.UserDisplayName: Chris Burgess
Body: <p>I am building a Docker container for CiviCRM, it is 99.9% done. Unfortunately, when I try to install the actual module via Drush, it spits out an error. I am fairly certain this isn't a Docker related issue, hopefully someone here has advice or direction.</p>
  
  <p>The error that is thrown:</p>
  
  <blockquote>
    <p>Cannot execute INSERT INTO (snip) ;: DB Error: already exists Drush command terminated abnormally due to an unrecoverable error</p>
  </blockquote>
  
  <p>The full error, including (snip) can be found below.</p>
  
  <p>Now, I dug around the Drush command script and it appears that the issue originates at the <a href="https://github.com/civicrm/civicrm-drupal/blob/7.x-master/drush/civicrm.drush.inc#L388" rel="nofollow">_civicrm_install_db</a> function. Specifically, before line 390 as that log entry is never printed.</p>
  
  <p>I did some looking through the JIRA bug tracker and found two possibly related issues. The first <a href="https://issues.civicrm.org/jira/browse/CRM-17874" rel="nofollow">CRM-17874</a> mentions the mysql:// database call, I tried patching the file and the same error is being thrown. The second <a href="https://issues.civicrm.org/jira/browse/CRM-18120" rel="nofollow">CRM-18120</a> mentions Deadlocks which seems highly plausible, but I did not see an easy patch.</p>
  
  <p>Anyway, I have asked for advice on IRC but to no avail as of yet. Please let me know if you have any solutions or thoughts. I will check here frequently as well as being available for synchronous chat in IRC.</p>
  
  <p>Thanks!</p>
  
  <p><strong>Edit 1:</strong> Here is the Drush command being run for installation:
  <code>
  drush -y civicrm-install \
    --dbuser=${MYSQL_USER} \
    --dbpass=${MYSQL_PASSWORD} \
    --dbhost=db \
    --dbname=${MYSQL_DATABASE_CIVICRM} \
    --tarfile=/var/www/civicrm.tar.gz \
    --destination=sites/all/modules \
    --site_url=${VIRTUAL_HOST} \
    --ssl=on \
    --load_generated_data=false
  </code></p>
  
  <p>(full error)</p>
  
  <blockquote>
    <p>Cannot execute INSERT INTO <code>civicrm_acl</code> (<code>id</code>, <code>name</code>, <code>deny</code>, <code>entity_table</code>, <code>entity_id</code>, <code>operation</code>, <code>object_table</code>, <code>object_id</code>, <code>acl_table</code>, <code>acl_id</code>, <code>is_active</code>) VALUES (1,'Edit All Contacts',0,'civicrm_acl_role',1,'Edit','civicrm_saved_search',0,NULL,NULL,1),(2,'Core ACL',0,'civicrm_acl_role',0,'All','access CiviMail subscribe/unsubscribe pages',NULL,NULL,NULL,1),(3,'Core ACL',0,'civicrm_acl_role',0,'All','access all custom data',NULL,NULL,NULL,1),(4,'Core ACL',0,'civicrm_acl_role',0,'All','make online contributions',NULL,NULL,NULL,1),(5,'Core ACL',0,'civicrm_acl_role',0,'All','make online pledges',NULL,NULL,NULL,1),(6,'Core ACL',0,'civicrm_acl_role',0,'All','profile listings and forms',NULL,NULL,NULL,1),(7,'Core ACL',0,'civicrm_acl_role',0,'All','view event info',NULL,NULL,NULL,1),(8,'Core ACL',0,'civicrm_acl_role',0,'All','register for events',NULL,NULL,NULL,1),(9,'Core ACL',0,'civicrm_acl_role',1,'All','access CiviCRM',NULL,NULL,NULL,1),(10,'Core ACL',0,'civicrm_acl_role',1,'All','access CiviContribute',NULL,NULL,NULL,1),(11,'Core ACL',0,'civicrm_acl_role',1,'All','access CiviEvent',NULL,NULL,NULL,1),(12,'Core ACL',0,'civicrm_acl_role',1,'All','access CiviMail',NULL,NULL,NULL,1),(13,'Core ACL',0,'civicrm_acl_role',1,'All','access CiviMail subscribe/unsubscribe pages',NULL,NULL,NULL,1),(14,'Core ACL',0,'civicrm_acl_role',1,'All','access CiviMember',NULL,NULL,NULL,1),(15,'Core ACL',0,'civicrm_acl_role',1,'All','access CiviPledge',NULL,NULL,NULL,1),(16,'Core ACL',0,'civicrm_acl_role',1,'All','administer CiviCase',NULL,NULL,NULL,1),(17,'Core ACL',0,'civicrm_acl_role',1,'All','access my cases and activities',NULL,NULL,NULL,1),(18,'Core ACL',0,'civicrm_acl_role',1,'All','access all cases and activities',NULL,NULL,NULL,1),(19,'Core ACL',0,'civicrm_acl_role',1,'All','delete in CiviCase',NULL,NULL,NULL,1),(20,'Core ACL',0,'civicrm_acl_role',1,'All','access CiviGrant',NULL,NULL,NULL,1),(21,'Core ACL',0,'civicrm_acl_role',1,'All','access Contact Dashboard',NULL,NULL,NULL,1),(22,'Core ACL',0,'civicrm_acl_role',1,'All','administer Multiple Organizations',NULL,NULL,NULL,1),(23,'Core ACL',0,'civicrm_acl_role',1,'All','delete activities',NULL,NULL,NULL,1),(24,'Core ACL',0,'civicrm_acl_role',1,'All','delete in CiviContribute',NULL,NULL,NULL,1),(25,'Core ACL',0,'civicrm_acl_role',1,'All','delete in CiviMail',NULL,NULL,NULL,1),(26,'Core ACL',0,'civicrm_acl_role',1,'All','delete in CiviPledge',NULL,NULL,NULL,1),(27,'Core ACL',0,'civicrm_acl_role',1,'All','delete contacts',NULL,NULL,NULL,1),(28,'Core ACL',0,'civicrm_acl_role',1,'All','delete in CiviEvent',NULL,NULL,NULL,1),(29,'Core ACL',0,'civicrm_acl_role',1,'All','delete in CiviMember',NULL,NULL,NULL,1),(30,'Core ACL',0,'civicrm_acl_role',1,'All','translate CiviCRM',NULL,NULL,NULL,1),(31,'Core ACL',0,'civicrm_acl_role',1,'All','edit grants',NULL,NULL,NULL,1),(32,'Core ACL',0,'civicrm_acl_role',1,'All','access all custom data',NULL,NULL,NULL,1),(33,'Core ACL',0,'civicrm_acl_role',1,'All','access uploaded files',NULL,NULL,NULL,1),(34,'Core ACL',0,'civicrm_acl_role',1,'All','add contacts',NULL,NULL,NULL,1),(35,'Core ACL',0,'civicrm_acl_role',1,'All','administer CiviCRM',NULL,NULL,NULL,1),(36,'Core ACL',0,'civicrm_acl_role',1,'All','edit all contacts',NULL,NULL,NULL,1),(37,'Core ACL',0,'civicrm_acl_role',1,'All','edit contributions',NULL,NULL,NULL,1),(38,'Core ACL',0,'civicrm_acl_role',1,'All','edit event participants',NULL,NULL,NULL,1),(39,'Core ACL',0,'civicrm_acl_role',1,'All','edit groups',NULL,NULL,NULL,1),(40,'Core ACL',0,'civicrm_acl_role',1,'All','edit memberships',NULL,NULL,NULL,1),(41,'Core ACL',0,'civicrm_acl_role',1,'All','edit pledges',NULL,NULL,NULL,1),(42,'Core ACL',0,'civicrm_acl_role',1,'All','access CiviReport',NULL,NULL,NULL,1),(43,'Core ACL',0,'civicrm_acl_role',1,'All','access Report Criteria',NULL,NULL,NULL,1),(44,'Core ACL',0,'civicrm_acl_role',1,'All','administer Reports',NULL,NULL,NULL,1),(45,'Core ACL',0,'civicrm_acl_role',1,'All','import contacts',NULL,NULL,NULL,1),(46,'Core ACL',0,'civicrm_acl_role',1,'All','make online contributions',NULL,NULL,NULL,1),(47,'Core ACL',0,'civicrm_acl_role',1,'All','make online pledges',NULL,NULL,NULL,1),(48,'Core ACL',0,'civicrm_acl_role',1,'All','profile listings and forms',NULL,NULL,NULL,1),(49,'Core ACL',0,'civicrm_acl_role',1,'All','profile create',NULL,NULL,NULL,1),(50,'Core ACL',0,'civicrm_acl_role',1,'All','profile edit',NULL,NULL,NULL,1),(51,'Core ACL',0,'civicrm_acl_role',1,'All','profile listings',NULL,NULL,NULL,1),(52,'Core ACL',0,'civicrm_acl_role',1,'All','profile view',NULL,NULL,NULL,1),(53,'Core ACL',0,'civicrm_acl_role',1,'All','register for events',NULL,NULL,NULL,1),(54,'Core ACL',0,'civicrm_acl_role',1,'All','view all activities',NULL,NULL,NULL,1),(55,'Core ACL',0,'civicrm_acl_role',1,'All','view all contacts',NULL,NULL,NULL,1),(56,'Core ACL',0,'civicrm_acl_role',1,'All','view event info',NULL,NULL,NULL,1),(57,'Core ACL',0,'civicrm_acl_role',1,'All','view event participants',NULL,NULL,NULL,1),(58,'Core ACL',0,'civicrm_acl_role',1,'All','edit all events',NULL,NULL,NULL,1),(59,'Core ACL',0,'civicrm_acl_role',2,'All','access CiviMail subscribe/unsubscribe pages',NULL,NULL,NULL,1),(60,'Core ACL',0,'civicrm_acl_role',2,'All','access all custom data',NULL,NULL,NULL,1),(61,'Core ACL',0,'civicrm_acl_role',2,'All','make online contributions',NULL,NULL,NULL,1),(62,'Core ACL',0,'civicrm_acl_role',2,'All','make online pledges',NULL,NULL,NULL,1),(63,'Core ACL',0,'civicrm_acl_role',2,'All','profile listings and forms',NULL,NULL,NULL,1),(64,'Core ACL',0,'civicrm_acl_role',2,'All','register for events',NULL,NULL,NULL,1),(65,'Core ACL',0,'civicrm_acl_role',2,'All','view event info',NULL,NULL,NULL,1);: DB Error: already existsDrush command terminated abnormally due to an unrecoverable error.       [error]</p>
  </blockquote>
  
Tags: <drupal><database><installation><issues><drush>
Title: Drush failing to build database during new installation
ThreadText: # Drush failing to build database during new installation
  
  (Asked by: username_0 on 2016-03-27)
  
  I am building a Docker container for CiviCRM, it is 99.9% done. Unfortunately, when I try to install the actual module via Drush, it spits out an error. I am fairly certain this isn't a Docker related issue, hopefully someone here has advice or direction.
  
  The error that is thrown:
  
  > Cannot execute INSERT INTO (snip) ;: DB Error: already exists Drush command terminated abnormally due to an unrecoverable error
  
  The full error, including (snip) can be found below.
  
  Now, I dug around the Drush command script and it appears that the issue originates at the [\_civicrm\_install\_db](https://github.com/civicrm/civicrm-drupal/blob/7.x-master/drush/civicrm.drush.inc#L388) function. Specifically, before line 390 as that log entry is never printed.
  
  I did some looking through the JIRA bug tracker and found two possibly related issues. The first [CRM-17874](https://issues.civicrm.org/jira/browse/CRM-17874) mentions the mysql:// database call, I tried patching the file and the same error is being thrown. The second [CRM-18120](https://issues.civicrm.org/jira/browse/CRM-18120) mentions Deadlocks which seems highly plausible, but I did not see an easy patch.
  
  Anyway, I have asked for advice on IRC but to no avail as of yet. Please let me know if you have any solutions or thoughts. I will check here frequently as well as being available for synchronous chat in IRC.
  
  Thanks!
  
  **Edit 1:** Here is the Drush command being run for installation:
  `drush -y civicrm-install \
  --dbuser=${MYSQL_USER} \
  --dbpass=${MYSQL_PASSWORD} \
  --dbhost=db \
  --dbname=${MYSQL_DATABASE_CIVICRM} \
  --tarfile=/var/www/civicrm.tar.gz \
  --destination=sites/all/modules \
  --site_url=${VIRTUAL_HOST} \
  --ssl=on \
  --load_generated_data=false`
  
  (full error)
  
  > Cannot execute INSERT INTO `civicrm_acl` (`id`, `name`, `deny`, `entity_table`, `entity_id`, `operation`, `object_table`, `object_id`, `acl_table`, `acl_id`, `is_active`) VALUES (1,'Edit All Contacts',0,'civicrm\_acl\_role',1,'Edit','civicrm\_saved\_search',0,NULL,NULL,1),(2,'Core ACL',0,'civicrm\_acl\_role',0,'All','access CiviMail subscribe/unsubscribe pages',NULL,NULL,NULL,1),(3,'Core ACL',0,'civicrm\_acl\_role',0,'All','access all custom data',NULL,NULL,NULL,1),(4,'Core ACL',0,'civicrm\_acl\_role',0,'All','make online contributions',NULL,NULL,NULL,1),(5,'Core ACL',0,'civicrm\_acl\_role',0,'All','make online pledges',NULL,NULL,NULL,1),(6,'Core ACL',0,'civicrm\_acl\_role',0,'All','profile listings and forms',NULL,NULL,NULL,1),(7,'Core ACL',0,'civicrm\_acl\_role',0,'All','view event info',NULL,NULL,NULL,1),(8,'Core ACL',0,'civicrm\_acl\_role',0,'All','register for events',NULL,NULL,NULL,1),(9,'Core ACL',0,'civicrm\_acl\_role',1,'All','access CiviCRM',NULL,NULL,NULL,1),(10,'Core ACL',0,'civicrm\_acl\_role',1,'All','access CiviContribute',NULL,NULL,NULL,1),(11,'Core ACL',0,'civicrm\_acl\_role',1,'All','access CiviEvent',NULL,NULL,NULL,1),(12,'Core ACL',0,'civicrm\_acl\_role',1,'All','access CiviMail',NULL,NULL,NULL,1),(13,'Core ACL',0,'civicrm\_acl\_role',1,'All','access CiviMail subscribe/unsubscribe pages',NULL,NULL,NULL,1),(14,'Core ACL',0,'civicrm\_acl\_role',1,'All','access CiviMember',NULL,NULL,NULL,1),(15,'Core ACL',0,'civicrm\_acl\_role',1,'All','access CiviPledge',NULL,NULL,NULL,1),(16,'Core ACL',0,'civicrm\_acl\_role',1,'All','administer CiviCase',NULL,NULL,NULL,1),(17,'Core ACL',0,'civicrm\_acl\_role',1,'All','access my cases and activities',NULL,NULL,NULL,1),(18,'Core ACL',0,'civicrm\_acl\_role',1,'All','access all cases and activities',NULL,NULL,NULL,1),(19,'Core ACL',0,'civicrm\_acl\_role',1,'All','delete in CiviCase',NULL,NULL,NULL,1),(20,'Core ACL',0,'civicrm\_acl\_role',1,'All','access CiviGrant',NULL,NULL,NULL,1),(21,'Core ACL',0,'civicrm\_acl\_role',1,'All','access Contact Dashboard',NULL,NULL,NULL,1),(22,'Core ACL',0,'civicrm\_acl\_role',1,'All','administer Multiple Organizations',NULL,NULL,NULL,1),(23,'Core ACL',0,'civicrm\_acl\_role',1,'All','delete activities',NULL,NULL,NULL,1),(24,'Core ACL',0,'civicrm\_acl\_role',1,'All','delete in CiviContribute',NULL,NULL,NULL,1),(25,'Core ACL',0,'civicrm\_acl\_role',1,'All','delete in CiviMail',NULL,NULL,NULL,1),(26,'Core ACL',0,'civicrm\_acl\_role',1,'All','delete in CiviPledge',NULL,NULL,NULL,1),(27,'Core ACL',0,'civicrm\_acl\_role',1,'All','delete contacts',NULL,NULL,NULL,1),(28,'Core ACL',0,'civicrm\_acl\_role',1,'All','delete in CiviEvent',NULL,NULL,NULL,1),(29,'Core ACL',0,'civicrm\_acl\_role',1,'All','delete in CiviMember',NULL,NULL,NULL,1),(30,'Core ACL',0,'civicrm\_acl\_role',1,'All','translate CiviCRM',NULL,NULL,NULL,1),(31,'Core ACL',0,'civicrm\_acl\_role',1,'All','edit grants',NULL,NULL,NULL,1),(32,'Core ACL',0,'civicrm\_acl\_role',1,'All','access all custom data',NULL,NULL,NULL,1),(33,'Core ACL',0,'civicrm\_acl\_role',1,'All','access uploaded files',NULL,NULL,NULL,1),(34,'Core ACL',0,'civicrm\_acl\_role',1,'All','add contacts',NULL,NULL,NULL,1),(35,'Core ACL',0,'civicrm\_acl\_role',1,'All','administer CiviCRM',NULL,NULL,NULL,1),(36,'Core ACL',0,'civicrm\_acl\_role',1,'All','edit all contacts',NULL,NULL,NULL,1),(37,'Core ACL',0,'civicrm\_acl\_role',1,'All','edit contributions',NULL,NULL,NULL,1),(38,'Core ACL',0,'civicrm\_acl\_role',1,'All','edit event participants',NULL,NULL,NULL,1),(39,'Core ACL',0,'civicrm\_acl\_role',1,'All','edit groups',NULL,NULL,NULL,1),(40,'Core ACL',0,'civicrm\_acl\_role',1,'All','edit memberships',NULL,NULL,NULL,1),(41,'Core ACL',0,'civicrm\_acl\_role',1,'All','edit pledges',NULL,NULL,NULL,1),(42,'Core ACL',0,'civicrm\_acl\_role',1,'All','access CiviReport',NULL,NULL,NULL,1),(43,'Core ACL',0,'civicrm\_acl\_role',1,'All','access Report Criteria',NULL,NULL,NULL,1),(44,'Core ACL',0,'civicrm\_acl\_role',1,'All','administer Reports',NULL,NULL,NULL,1),(45,'Core ACL',0,'civicrm\_acl\_role',1,'All','import contacts',NULL,NULL,NULL,1),(46,'Core ACL',0,'civicrm\_acl\_role',1,'All','make online contributions',NULL,NULL,NULL,1),(47,'Core ACL',0,'civicrm\_acl\_role',1,'All','make online pledges',NULL,NULL,NULL,1),(48,'Core ACL',0,'civicrm\_acl\_role',1,'All','profile listings and forms',NULL,NULL,NULL,1),(49,'Core ACL',0,'civicrm\_acl\_role',1,'All','profile create',NULL,NULL,NULL,1),(50,'Core ACL',0,'civicrm\_acl\_role',1,'All','profile edit',NULL,NULL,NULL,1),(51,'Core ACL',0,'civicrm\_acl\_role',1,'All','profile listings',NULL,NULL,NULL,1),(52,'Core ACL',0,'civicrm\_acl\_role',1,'All','profile view',NULL,NULL,NULL,1),(53,'Core ACL',0,'civicrm\_acl\_role',1,'All','register for events',NULL,NULL,NULL,1),(54,'Core ACL',0,'civicrm\_acl\_role',1,'All','view all activities',NULL,NULL,NULL,1),(55,'Core ACL',0,'civicrm\_acl\_role',1,'All','view all contacts',NULL,NULL,NULL,1),(56,'Core ACL',0,'civicrm\_acl\_role',1,'All','view event info',NULL,NULL,NULL,1),(57,'Core ACL',0,'civicrm\_acl\_role',1,'All','view event participants',NULL,NULL,NULL,1),(58,'Core ACL',0,'civicrm\_acl\_role',1,'All','edit all events',NULL,NULL,NULL,1),(59,'Core ACL',0,'civicrm\_acl\_role',2,'All','access CiviMail subscribe/unsubscribe pages',NULL,NULL,NULL,1),(60,'Core ACL',0,'civicrm\_acl\_role',2,'All','access all custom data',NULL,NULL,NULL,1),(61,'Core ACL',0,'civicrm\_acl\_role',2,'All','make online contributions',NULL,NULL,NULL,1),(62,'Core ACL',0,'civicrm\_acl\_role',2,'All','make online pledges',NULL,NULL,NULL,1),(63,'Core ACL',0,'civicrm\_acl\_role',2,'All','profile listings and forms',NULL,NULL,NULL,1),(64,'Core ACL',0,'civicrm\_acl\_role',2,'All','register for events',NULL,NULL,NULL,1),(65,'Core ACL',0,'civicrm\_acl\_role',2,'All','view event info',NULL,NULL,NULL,1);: DB Error: already existsDrush command terminated abnormally due to an unrecoverable error. [error]
  
  **Tags:** drupal, database, installation, issues, drush
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2016-03-28. Score: 1 | Accepted answer
  
  After doing some print-line debugging, I traced the issue to [line 413](https://github.com/civicrm/civicrm-drupal/blob/7.x-master/drush/civicrm.drush.inc#L413) which determines whether or not pre-generated demo data should be loaded.
  
  I have tried a variety of combinations to no avail:
  `load_generated_data=false
  load_generated_data=FALSE
  load_generated_data="FALSE"`
  
  As I am out of ideas, for now the flag is just going to be removed from my script. However, it appears that this is a bug with the Drush command.
  
  Thanks to everyone who took a look and offered advice, here and on IRC.
  
  **Edit:** load\_generated\_data=0 WORKS!
  
  > **Comments:**
  > **username_1**: Did you try `--load-generated-data=0`? Most strings, including "false", evaluate to true: `php -r "if ('false') print 'yes';" // => 'yes'`  
  
  ---
  
  ### Answer by username_1 on 2016-03-28. Score: 2
  
  This error can happen if you attempt to load a CiviCRM DB over the top of an existing DB. It's possible that's what you're running into here.
  
  Looks like there are two files in the CiviCRM distribution which might try to populate that table, so make sure you aren't getting both executed.
  
  * `civicrm/sql/civicrm_acl.mysql`
  * `civicrm/sql/civicrm_generated.mysql`
  
  But this is speculative - can you describe in detail how you're installing CiviCRM via Drush? That might help someone reproduce the error you're hitting or give a more definite reply.
  
  
  ---
  
  