Answers.Body: <p>Found how to resolve this one, but bit concerned that this fudge might break something further on down the line.</p>
  
  <p>The CiviCRM installer page is driven by the file: <code>wp-content/plugins/civicrm/civicrm/install/index.php</code>.</p>
  
  <p>This runs various checks and the db name check is on line 464 showing a call to CRM_Core_DAO to function requireValidDBName.</p>
  
  <p>This function is in php file: <code>wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php</code>.  Editing the <code>preg_match</code> string to include hyphens after the underscore allows these in the file name.</p>
  
  <pre><code>public static function requireValidDBName($database) {
    $matches = array();
    preg_match(
      "/^[0-9]*[a-zA-Z_-]+[a-zA-Z0-9_-]*$/",
      $database,
      $matches
    );
    if (empty($matches)) {
      return FALSE;
    }
    return TRUE;
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-26T02:27:36.280Z
Answers.LastActivityDate: 2016-09-29T19:50:12.197Z
Answers.LastEditDate: 2016-09-29T19:50:12.197Z
Answers.UserDisplayName: Eric Booth
Body: <p>Is there any way we can work around this? </p>
  
  <p>Our Joomla install was quite happy to use a db of format xxnn-yyyyyy.  </p>
  
  <p>When we create or rename db using phpMyAdmin we can only choose the yyyyyy. "xxnn-" is automatic.</p>
  
  <p>The CiviCRM Installer had an error to the question
  "Is the provided database name valid?   The database name provided is not valid. Please use only 0-9, a-z, A-Z and _ as characters in the name."</p>
  
Tags: <wordpress><database><installation>
Title: Database name on Wordpress can't include hyphen, but our host has mandatory prefix-hyphen-name format
ThreadText: # Database name on Wordpress can't include hyphen, but our host has mandatory prefix-hyphen-name format
  
  (Asked by: username_0 on 2016-06-24)
  
  Is there any way we can work around this?
  
  Our Joomla install was quite happy to use a db of format xxnn-yyyyyy.
  
  When we create or rename db using phpMyAdmin we can only choose the yyyyyy. "xxnn-" is automatic.
  
  The CiviCRM Installer had an error to the question
  "Is the provided database name valid? The database name provided is not valid. Please use only 0-9, a-z, A-Z and \_ as characters in the name."
  
  **Tags:** wordpress, database, installation
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2016-06-26. Score: 2 | Accepted answer
  
  Found how to resolve this one, but bit concerned that this fudge might break something further on down the line.
  
  The CiviCRM installer page is driven by the file: `wp-content/plugins/civicrm/civicrm/install/index.php`.
  
  This runs various checks and the db name check is on line 464 showing a call to CRM\_Core\_DAO to function requireValidDBName.
  
  This function is in php file: `wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php`. Editing the `preg_match` string to include hyphens after the underscore allows these in the file name.
  
  ```
  public static function requireValidDBName($database) {
    $matches = array();
    preg_match(
      "/^[0-9]*[a-zA-Z_-]+[a-zA-Z0-9_-]*$/",
      $database,
      $matches
    );
    if (empty($matches)) {
      return FALSE;
    }
    return TRUE;
  }
  
  ```
  
  
  ---
  
  