Answers.Body: <p>You will need to export the database without triggers and import them back and rebuild the trigger</p>
  <pre><code>mysqldump -umysqlusername -p --skip-triggers dbname &gt; dbname.mysql
  
  drop database dbname;
  
  create database dbname;
  
  mysql -umysqlusername -p dbname &lt; dbname.mysql
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-02-11T14:41:27.253Z
Answers.LastActivityDate: 2024-02-11T14:41:27.253Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>I updated CiviCRM on Drupal 7 to the latest version (5.70.0) in Production. I then copied the production environment into a development URL on the same server, and updated /sites/default/civicrm.settings.php as well as /sites/default/settings.php to point the Sandbox to the development database.</p>
  <p><code>CIVICRM_UF_DSN</code>, <code>CIVICRM_DSN</code>, <code>$civicrm_root</code>, and <code>CIVICRM_TEMPLATE_COMPILEDIR</code> all now point to the development database.</p>
  <p>The development site loads fine a web browser, and when I update data from Drupal, that data gets updated in the Dev database with no problem. But when I try to update something in CiviCRM, such as enable or disable an extension, create a new contact, or even when I go to manually run the cron job against the development environment, I get the following error:</p>
  <blockquote>
  <p>DB Error: insufficient permissions</p>
  </blockquote>
  <p>Then when I go to check the log, I see something like the following, which is clearly using the Production (not the Dev) database user:</p>
  <blockquote>
  <p>[nativecode=1142 ** TRIGGER command denied to user 'production-user'@'localhost' for table 'civicrm_contact']&quot;`</p>
  </blockquote>
  <p>I have cleared caches several times, having deleted files in <code>/sites/default/files/civicrm/templates_c</code>. I have grepped the entire Development codebase for the <code>production-user</code>, and it is nowhere to be seen.</p>
  <p>I have tried to rebuild the triggers by going to <code>civicrm/menu/rebuild?reset=1&amp;triggerRebuild=1</code>, but that produces the same error. I have also tried to rebuild the menu &amp; clear the cache from the web UI, but that also produces the same error.</p>
  <p>How can I track down why the Development copy of this website is still somehow trying to use the Production database user (and is it still somehow trying to connect to the prod database too)?</p>
  
Tags: <database>
Title: Development site is connecting to production database (DB Error: insufficient permissions)
ThreadText: # Development site is connecting to production database (DB Error: insufficient permissions)
  
  (Asked by: username_0 on 2024-02-11)
  
  I updated CiviCRM on Drupal 7 to the latest version (5.70.0) in Production. I then copied the production environment into a development URL on the same server, and updated /sites/default/civicrm.settings.php as well as /sites/default/settings.php to point the Sandbox to the development database.
  
  `CIVICRM_UF_DSN`, `CIVICRM_DSN`, `$civicrm_root`, and `CIVICRM_TEMPLATE_COMPILEDIR` all now point to the development database.
  
  The development site loads fine a web browser, and when I update data from Drupal, that data gets updated in the Dev database with no problem. But when I try to update something in CiviCRM, such as enable or disable an extension, create a new contact, or even when I go to manually run the cron job against the development environment, I get the following error:
  
  > DB Error: insufficient permissions
  
  Then when I go to check the log, I see something like the following, which is clearly using the Production (not the Dev) database user:
  
  > [nativecode=1142 \*\* TRIGGER command denied to user 'production-user'@'localhost' for table 'civicrm\_contact']"`
  
  I have cleared caches several times, having deleted files in `/sites/default/files/civicrm/templates_c`. I have grepped the entire Development codebase for the `production-user`, and it is nowhere to be seen.
  
  I have tried to rebuild the triggers by going to `civicrm/menu/rebuild?reset=1&triggerRebuild=1`, but that produces the same error. I have also tried to rebuild the menu & clear the cache from the web UI, but that also produces the same error.
  
  How can I track down why the Development copy of this website is still somehow trying to use the Production database user (and is it still somehow trying to connect to the prod database too)?
  
  **Tags:** database
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-02-11. Score: 0
  
  You will need to export the database without triggers and import them back and rebuild the trigger
  mysqldump -umysqlusername -p --skip-triggers dbname > dbname.mysql
  
  drop database dbname;
  
  create database dbname;
  
  mysql -umysqlusername -p dbname < dbname.mysql
  
  
  ---
  
  