Answers.Body: <p>I solved this.  ::Wipes sweat from brow:: In Drupal 9 you can no longer use database prefixes syntax.</p>
  <p>This syntax no longer works: &quot;$databases['default']['default']['prefix']= array()&quot;</p>
  <p>Without this syntax a new database array is needed. Something like this:</p>
  <pre><code>$databases['civicrm']['default'] = array (
  'database' =&gt; 'civicrm_dev',
  </code></pre>
  <p>'username' =&gt; 'user',
  'password' =&gt; 'password',
  'host' =&gt; 'name-cluster-cluster.cluster-someID.us-west-2.rds.amazonaws.com',
  'port' =&gt; '3306',
  'namespace' =&gt; 'Drupal\Core\Database\Driver\mysql',
  'driver' =&gt; 'mysql',
  );</p>
  <p>See also: <a href="https://www.drupal.org/project/civicrm_entity/issues/3198146#comment-14352132" rel="nofollow noreferrer">https://www.drupal.org/project/civicrm_entity/issues/3198146#comment-14352132</a></p>
  <p>When I updated the settings file for Drupal I only changed the MySQL host once missing the connection to the CiviCRM database in the settings.php file.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-07-27T02:13:55.703Z
Answers.Text: Great you solved it! But it's not a "new" thing - you have always had the option of storing drupal and civi in the same mysql database or separate databases, so that must have got mixed up during the restore or somewhere.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-07-28T08:25:25.063Z
Answers.Text: @Demerit, I made some clarifications.  I hope this better states what I was trying to say :).
Answers.UserDisplayName: Josh
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-07-27T01:57:16.183Z
Answers.LastActivityDate: 2022-07-28T08:24:45.000Z
Answers.LastEditDate: 2022-07-28T08:24:45.000Z
Answers.UserDisplayName: Josh
Body: <p>I have a CiviCRM instance that has its database hosted in RDS Aurora.  This has worked well for several years.  Recently I needed to restore from a copy of the Aurora cluster and I changed the name of the endpoint (database server).  Nothing else changed. The change is working for the Drupal database and for CiviCRM some of the time.</p>
  <p>I am using Drupal 9.3.6 and CiviCRM 5.46.2.</p>
  <p>If I go to mysite.org/civicrm CiviCRM comes up well. If I go to a page that pulls CiviCRM data into Drupal Views then it cannot connect. My views could connect before this change was made. If I use the cv sql command from the command line I get access denied. If I copy and paste (meaning to reduce potential errors) from the file created by the CV command to access MySQL I can access the database.</p>
  <p>Looking at the logs it appears that the connection fails for anything using API V3.  I have tried to upgrade CiviCRM to see if that would solve this problem and the upgrade fails trying to determine installed extensions using a call to API V3.</p>
  <p>I have checked all of the settings on the Aurora end and the restored cluster has the same settings as the cluster that has since been deleted.</p>
  <p>Any help or suggestions on what to check are greatly appreciated.</p>
  <p>Thanks,
  Josh</p>
  
Tags: <drupal><api><database><drupal-views>
Title: Database Connection Only Works Some of the Time
ThreadText: # Database Connection Only Works Some of the Time
  
  (Asked by: username_0 on 2022-07-15)
  
  I have a CiviCRM instance that has its database hosted in RDS Aurora. This has worked well for several years. Recently I needed to restore from a copy of the Aurora cluster and I changed the name of the endpoint (database server). Nothing else changed. The change is working for the Drupal database and for CiviCRM some of the time.
  
  I am using Drupal 9.3.6 and CiviCRM 5.46.2.
  
  If I go to mysite.org/civicrm CiviCRM comes up well. If I go to a page that pulls CiviCRM data into Drupal Views then it cannot connect. My views could connect before this change was made. If I use the cv sql command from the command line I get access denied. If I copy and paste (meaning to reduce potential errors) from the file created by the CV command to access MySQL I can access the database.
  
  Looking at the logs it appears that the connection fails for anything using API V3. I have tried to upgrade CiviCRM to see if that would solve this problem and the upgrade fails trying to determine installed extensions using a call to API V3.
  
  I have checked all of the settings on the Aurora end and the restored cluster has the same settings as the cluster that has since been deleted.
  
  Any help or suggestions on what to check are greatly appreciated.
  
  Thanks,
  username_0
  
  **Tags:** drupal, api, database, drupal-views
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2022-07-27. Score: 1
  
  I solved this. ::Wipes sweat from brow:: In Drupal 9 you can no longer use database prefixes syntax.
  
  This syntax no longer works: "$databases['default']['default']['prefix']= array()"
  
  Without this syntax a new database array is needed. Something like this:
  
  ```
  $databases['civicrm']['default'] = array (
  'database' => 'civicrm_dev',
  
  ```
  
  'username' => 'user',
  'password' => 'password',
  'host' => 'name-cluster-cluster.cluster-someID.us-west-2.rds.amazonaws.com',
  'port' => '3306',
  'namespace' => 'Drupal\Core\Database\Driver\mysql',
  'driver' => 'mysql',
  );
  
  See also: <https://www.drupal.org/project/civicrm_entity/issues/3198146#comment-14352132>
  
  When I updated the settings file for Drupal I only changed the MySQL host once missing the connection to the CiviCRM database in the settings.php file.
  
  > **Comments:**
  > **username_1**: Great you solved it! But it's not a "new" thing - you have always had the option of storing drupal and civi in the same mysql database or separate databases, so that must have got mixed up during the restore or somewhere.  
  > **username_0**: @username_1, I made some clarifications.  I hope this better states what I was trying to say :).  
  
  ---
  
  