Answers.Body: <p>I checked a site that is currently being test-upgraded from 4.4.14 to 4.6.4, so we have both the 4.4.14 and 4.6.4 versions.</p>
  
  <p>In 4.4.14:
  GRANT EXECUTE, ALTER ROUTINE ON FUNCTION <code>mycividb</code>.<code>civicrm_strip_non_numeric</code> TO 'myuser'@'localhost'</p>
  
  <p>In 4.6.4:
  GRANT EXECUTE, ALTER ROUTINE ON FUNCTION <code>mycividb</code>.<code>civicrm_strip_non_numeric</code> TO 'myuser'@'localhost'</p>
  
  <p>I.e. the same. This permission normally gets automatically granted for this function, when the function is created, which happens when triggers are set up. This is done automatically by MySQL:</p>
  
  <blockquote>
    <p>The EXECUTE privilege is required to execute stored routines. However,
    this privilege is granted automatically to the creator of a routine if
    necessary</p>
  </blockquote>
  
  <p><a href="https://dev.mysql.com/doc/refman/5.5/en/stored-routines-privileges.html" rel="nofollow">https://dev.mysql.com/doc/refman/5.5/en/stored-routines-privileges.html</a></p>
  
  <p>From the MariaDB docs:</p>
  
  <blockquote>
    <p>To run a stored routine, the EXECUTE privilege is needed. This is also
    temporarily granted to the creator if they attempt to run their
    routine unless the automatic_sp_privileges variable is set to 0.</p>
  </blockquote>
  
  <p><a href="https://mariadb.com/kb/en/mariadb/stored-routine-privileges/" rel="nofollow">https://mariadb.com/kb/en/mariadb/stored-routine-privileges/</a></p>
  
  <p>Worth checking the automatic_sp_privileges variable.</p>
  
  <p>Does a trigger rebuild (/civicrm/menu/rebuild?reset=1&amp;triggerRebuild=1) fix the problem?</p>
  
  <p>You say you solved the problem by adding the "execute" privilege to your drupal-db user. Did you mean your civicrm-db user? If you post the results of SHOW GRANTS for the relevant users, that might help to diagnose what's happening.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-10T11:14:27.030Z
Answers.Text: Hi
  - trigger rebuild did not fix the issue. (/civicrm/menu/rebuild?reset=1&triggerRebuild=1)
  - I added the execute permission to the civicrm-db user. (not drupal, my mistake). I used phpmyadmin to do so.
  - automatic_sp_priveleges variable = on
Answers.UserDisplayName: Johan Van Dyck
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-10T11:44:51.750Z
Answers.Text: The variable is "automatic_sp_privileges", not "automatic_sp_priveleges".
Answers.UserDisplayName: davejenx
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-10T10:29:31.407Z
Answers.LastActivityDate: 2015-07-10T10:37:26.933Z
Answers.LastEditDate: 2015-07-10T10:37:26.933Z
Answers.UserDisplayName: davejenx
Answers.Body: <p>As far as I know you also needed the execute privilige in earlier versions for the phone strip function?</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-10T08:33:59.360Z
Answers.LastActivityDate: 2015-07-10T08:33:59.360Z
Answers.UserDisplayName: ErikH - CiviCooP
Answers.Body: <p>CiviCRM requires additional DB permissions beyond what you'd normally require for a CMS like WordPress, Joomla or Drupal.</p>
  
  <p>When cloning a site for testing, the same permissions setup will need to be replicated for the cloned site. Just "stock" permissions won't do the trick :(</p>
  
  <p>These permissions are documented in the CiviCRM Wiki: <a href="https://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+MySQL+Permission+Requirements" rel="nofollow noreferrer">CiviCRM MySQL Permission Requirements</a></p>
  
  <hr>
  
  <p>Select your MySQL version below, then execute the appropriate permissions SQL after replacing <code>DBNAME</code>, <code>DBUSERNAME</code>, <code>DBHOSTNAME</code> and <code>DBPASSWORD</code> to suit your access.</p>
  
  <h2>MySQL >= 5.1.6</h2>
  
  <pre><code>GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, TRIGGER, CREATE ROUTINE, ALTER ROUTINE 
     ON DBNAME.* TO 'DBUSERNAME'@'DBHOSTNAME' IDENTIFIED BY 'DBPASSWORD';
  </code></pre>
  
  <h2>MySQL &lt;= 5.1.5</h2>
  
  <pre><code>GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, CREATE ROUTINE, ALTER ROUTINE 
     ON DBNAME.* TO 'DBUSERNAME'@'DBHOSTNAME' IDENTIFIED BY 'DBPASSWORD';
  GRANT SUPER ON *.* TO 'DBUSERNAME'@'DBHOSTNAME';
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-16T00:58:11.997Z
Answers.LastActivityDate: 2016-11-16T01:34:12.107Z
Answers.LastEditDate: 2016-11-16T01:34:12.107Z
Answers.UserDisplayName: Chris Burgess
Body: <p>I recently update civicrm till 4.6.2 till 4.6.4 on drupal 7.38, mariadb 5.5.41.
  When saving a contact with a non numeric phone number (+32 123456798) I got the error:</p>
  
  <p>Database foutcode: execute command denied to user 'civicrm-db-user'@'localhost' for routine 'civicrm-db.civicrm_strip_non_numeric', 1370</p>
  
  <pre><code>Array
  (
  [callback] =&gt; Array
      (
          [0] =&gt; CRM_Core_Error
          [1] =&gt; handle
      )
  
  [code] =&gt; -1
  [message] =&gt; DB Error: unknown error
  [mode] =&gt; 16
  [debug_info] =&gt; INSERT INTO civicrm_phone (contact_id , location_type_id , is_primary , is_billing , phone , phone_ext , phone_type_id ) VALUES ( 26 ,  1 ,  1 ,  0 , '+32' ,  NULL ,  1 )  [nativecode=1370 ** execute command denied to user 'civicrm-db-user'@'localhost' for routine 'civicrm-db.civicrm_strip_non_numeric']
  [type] =&gt; DB_Error
  [user_info] =&gt; INSERT INTO civicrm_phone (contact_id , location_type_id , is_primary , is_billing , phone , phone_ext , phone_type_id ) VALUES ( 26 ,  1 ,  1 ,  0 , '+32' ,  NULL ,  1 )  [nativecode=1370 ** execute command denied to user 'civicrm-db-user'@'localhost' for routine 'civicrm-db.civicrm_strip_non_numeric']
  [to_string] =&gt; [db_error: message="DB Error: unknown error" code=-1 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO civicrm_phone (contact_id , location_type_id , is_primary , is_billing , phone , phone_ext , phone_type_id ) VALUES ( 26 ,  1 ,  1 ,  0 , '+32' ,  NULL ,  1 )  [nativecode=1370 ** execute command denied to user 'civicrm-db-user'@'localhost' for routine 'civicrm-db.civicrm_strip_non_numeric']"]
  </code></pre>
  
  <p>)</p>
  
  <p>I found the solution in adding the "execute" privilege to my civicrm-db user in mariadb using phpmyadmin.</p>
  
  <p>I have a second civicrm db (non related to my first) still on the old version 4.6.2 which has no issues at all. I has no "execute" privilege and does not need it.</p>
  
  <p>Civicrm doc (<a href="http://forum.civicrm.org/index.php?topic=23489.0" rel="nofollow noreferrer">http://forum.civicrm.org/index.php?topic=23489.0</a>) does not mention execute privilege.</p>
  
  <p>list of grants to my civicrm user:
  Grants for civicrm-db-user@localhost </p>
  
  <pre><code>GRANT USAGE ON *.* TO 'civicrm-db-user'@'localhost' IDENTIFIED BY PASSWORD 'pwdhere'
  GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, CREATE ROUTINE, ALTER ROUTINE, TRIGGER ON `civicrm`.* TO 'civicrm-db-user'@'localhost'
  GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES ON `civi`.* TO 'civicrm-db-user'@'localhost'
  GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE ROUTINE, ALTER ROUTINE, TRIGGER ON `civicrm-db`.* TO 'civicrm-db-user'@'localhost'
  </code></pre>
  
  <p>trigger rebuild did not fix the issue. (/civicrm/menu/rebuild?reset=1&amp;triggerRebuild=1) </p>
  
  <p>automatic_sp_priveleges variable = on in mariadb </p>
  
  <p>Question: did I miss something in the update, does the latest version need different rights? I think I found a workaround, but not the actual error. Has someone the same issue?</p>
  
  <p>Kind regards</p>
  
  <p>Johan.</p>
  
Tags: <contacts><mysql>
Title: save contact with non numeric phone number gives access denied civicm_strip_non_numeric
ThreadText: # save contact with non numeric phone number gives access denied civicm_strip_non_numeric
  
  (Asked by: username_0 on 2015-07-09)
  
  I recently update civicrm till 4.6.2 till 4.6.4 on drupal 7.38, mariadb 5.5.41.
  When saving a contact with a non numeric phone number (+32 123456798) I got the error:
  Database foutcode: execute command denied to user 'civicrm-db-user'@'localhost' for routine 'civicrm-db.civicrm_strip_non_numeric', 1370
  Array
  (
  [callback] => Array
      (
          [0] => CRM_Core_Error
          [1] => handle
      )
  
  [code] => -1
  [message] => DB Error: unknown error
  [mode] => 16
  [debug_info] => INSERT INTO civicrm_phone (contact_id , location_type_id , is_primary , is_billing , phone , phone_ext , phone_type_id ) VALUES ( 26 ,  1 ,  1 ,  0 , '+32' ,  NULL ,  1 )  [nativecode=1370 ** execute command denied to user 'civicrm-db-user'@'localhost' for routine 'civicrm-db.civicrm_strip_non_numeric']
  [type] => DB_Error
  [user_info] => INSERT INTO civicrm_phone (contact_id , location_type_id , is_primary , is_billing , phone , phone_ext , phone_type_id ) VALUES ( 26 ,  1 ,  1 ,  0 , '+32' ,  NULL ,  1 )  [nativecode=1370 ** execute command denied to user 'civicrm-db-user'@'localhost' for routine 'civicrm-db.civicrm_strip_non_numeric']
  [to_string] => [db_error: message="DB Error: unknown error" code=-1 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO civicrm_phone (contact_id , location_type_id , is_primary , is_billing , phone , phone_ext , phone_type_id ) VALUES ( 26 ,  1 ,  1 ,  0 , '+32' ,  NULL ,  1 )  [nativecode=1370 ** execute command denied to user 'civicrm-db-user'@'localhost' for routine 'civicrm-db.civicrm_strip_non_numeric']"]
  
  )
  I found the solution in adding the "execute" privilege to my civicrm-db user in mariadb using phpmyadmin.
  I have a second civicrm db (non related to my first) still on the old version 4.6.2 which has no issues at all. I has no "execute" privilege and does not need it.
  Civicrm doc (http://forum.civicrm.org/index.php?topic=23489.0) does not mention execute privilege.
  list of grants to my civicrm user:
  Grants for civicrm-db-user@localhost 
  GRANT USAGE ON *.* TO 'civicrm-db-user'@'localhost' IDENTIFIED BY PASSWORD 'pwdhere'
  GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, CREATE ROUTINE, ALTER ROUTINE, TRIGGER ON `civicrm`.* TO 'civicrm-db-user'@'localhost'
  GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES ON `civi`.* TO 'civicrm-db-user'@'localhost'
  GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE ROUTINE, ALTER ROUTINE, TRIGGER ON `civicrm-db`.* TO 'civicrm-db-user'@'localhost'
  
  trigger rebuild did not fix the issue. (/civicrm/menu/rebuild?reset=1&triggerRebuild=1) 
  automatic_sp_priveleges variable = on in mariadb 
  Question: did I miss something in the update, does the latest version need different rights? I think I found a workaround, but not the actual error. Has someone the same issue?
  Kind regards
  Johan.
  
  **Tags:** contacts, mysql
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2015-07-10. Score: 2
  
  I checked a site that is currently being test-upgraded from 4.4.14 to 4.6.4, so we have both the 4.4.14 and 4.6.4 versions.
  
  In 4.4.14:
  GRANT EXECUTE, ALTER ROUTINE ON FUNCTION `mycividb`.`civicrm_strip_non_numeric` TO 'myuser'@'localhost'
  
  In 4.6.4:
  GRANT EXECUTE, ALTER ROUTINE ON FUNCTION `mycividb`.`civicrm_strip_non_numeric` TO 'myuser'@'localhost'
  
  I.e. the same. This permission normally gets automatically granted for this function, when the function is created, which happens when triggers are set up. This is done automatically by MySQL:
  
  > The EXECUTE privilege is required to execute stored routines. However,
  > this privilege is granted automatically to the creator of a routine if
  > necessary
  
  <https://dev.mysql.com/doc/refman/5.5/en/stored-routines-privileges.html>
  
  From the MariaDB docs:
  
  > To run a stored routine, the EXECUTE privilege is needed. This is also
  > temporarily granted to the creator if they attempt to run their
  > routine unless the automatic\_sp\_privileges variable is set to 0.
  
  <https://mariadb.com/kb/en/mariadb/stored-routine-privileges/>
  
  Worth checking the automatic\_sp\_privileges variable.
  
  Does a trigger rebuild (/civicrm/menu/rebuild?reset=1&triggerRebuild=1) fix the problem?
  
  You say you solved the problem by adding the "execute" privilege to your drupal-db user. Did you mean your civicrm-db user? If you post the results of SHOW GRANTS for the relevant users, that might help to diagnose what's happening.
  
  > **Comments:**
  > **username_0**: Hi - trigger rebuild did not fix the issue. (/civicrm/menu/rebuild?reset=1&triggerRebuild=1) - I added the execute permission to the civicrm-db user. (not drupal, my mistake). I used phpmyadmin to do so. - automatic_sp_priveleges variable = on  
  > **username_1**: The variable is "automatic_sp_privileges", not "automatic_sp_priveleges".  
  
  ---
  
  ### Answer by username_2 on 2015-07-10. Score: 0
  
  As far as I know you also needed the execute privilige in earlier versions for the phone strip function?
  
  
  ---
  
  ### Answer by username_3 on 2016-11-16. Score: 0
  
  CiviCRM requires additional DB permissions beyond what you'd normally require for a CMS like WordPress, Joomla or Drupal.
  When cloning a site for testing, the same permissions setup will need to be replicated for the cloned site. Just "stock" permissions won't do the trick :(
  These permissions are documented in the CiviCRM Wiki: CiviCRM MySQL Permission Requirements
  
  Select your MySQL version below, then execute the appropriate permissions SQL after replacing DBNAME, DBUSERNAME, DBHOSTNAME and DBPASSWORD to suit your access.
  MySQL >= 5.1.6
  GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, TRIGGER, CREATE ROUTINE, ALTER ROUTINE 
     ON DBNAME.* TO 'DBUSERNAME'@'DBHOSTNAME' IDENTIFIED BY 'DBPASSWORD';
  
  MySQL <= 5.1.5
  GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, CREATE ROUTINE, ALTER ROUTINE 
     ON DBNAME.* TO 'DBUSERNAME'@'DBHOSTNAME' IDENTIFIED BY 'DBPASSWORD';
  GRANT SUPER ON *.* TO 'DBUSERNAME'@'DBHOSTNAME';
  
  
  ---
  
  