After complete wipe and install new MYSQL 5.7.9 can't get fresh civi drupal up and running but existing drupal sites work fine. So I'd like to know if others can install on this combination or if a db downgrade is in order. Or something else? help!

My configuration:

OS X 10.11.1, MySQL 5.7.9, PHP 5.5.21, Drupal 7.41, CiviCRM 4.6.10

At first I was trying to migrate a site from live to local, many fails. So I stripped it down to the following steps...

  1. mysql drop database name
  2. mysql create database name
  3. untar drupal as ~/Sites/drupal
  4. localhost/drupal/install.php (Standard)
  5. untar civicrm in ~/Sites/drupal/sites/all/modules
  6. admin/config/development/maintenance set drupal maintenance mode
  7. chmod u+w sites/default
  8. sites/all/modules/civicrm/install/index.php

Install gives error below and subsequently module is enabled in drupal but all civicrm urls give a shorter version of the same error:


The website encountered an unexpected error. Please try again later.
Error message

Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in drupal_environment_initialize() (line 692 of /Users/rota/Sites/drupal/includes/bootstrap.inc).
CiviCRM_API3_Exception: DB Error: unknown error in civicrm_api3() (line 45 of /Users/rota/Sites/drupal/sites/all/modules/civicrm/api/api.php).
Status message

CiviCRM theme configuration setting is available under Administer > Appearance > Administration theme


North-Fork:ConfigAndLog rota$ cat Civicrm.cde18d9d66ead3de8f5c02e6d89d7355.log.201512010951
Nov 30 20:53:18  [info] $backTrace = #0 /Users/rota/Sites/drupal/sites/all/modules/civicrm/CRM/Core/Error.php(897): CRM_Core_Error::backtrace("backTrace", TRUE)
#1 [internal function](): CRM_Core_Error::exceptionHandler(Object(DB_Error))
#2 /Users/rota/Sites/drupal/sites/all/modules/civicrm/packages/PEAR.php(931): call_user_func((Array:2), Object(DB_Error))
#3 /Users/rota/Sites/drupal/sites/all/modules/civicrm/packages/DB.php(976): PEAR_Error->PEAR_Error("DB Error: unknown error", -1, 16, (Array:2), "SELECT GET_LOCK( 'pincsf.1.cache.CiviCRM setting Specs_settingsMetadata___nam...")
#4 /Users/rota/Sites/drupal/sites/all/modules/civicrm/packages/PEAR.php(564): DB_Error->DB_Error(-1, 16, (Array:2), "SELECT GET_LOCK( 'pincsf.1.cache.CiviCRM setting Specs_settingsMetadata___nam...")
#5 /Users/rota/Sites/drupal/sites/all/modules/civicrm/packages/DB/common.php(1905): PEAR->raiseError(NULL, -1, NULL, NULL, "SELECT GET_LOCK( 'pincsf.1.cache.CiviCRM setting Specs_settingsMetadata___nam...", "DB_Error", TRUE)
#6 /Users/rota/Sites/drupal/sites/all/modules/civicrm/packages/DB/mysql.php(895): DB_common->raiseError(-1, NULL, NULL, NULL, "3057 ** Incorrect user-level lock name 'pincsf.1.cache.CiviCRM setting Specs_...")
#7 /Users/rota/Sites/drupal/sites/all/modules/civicrm/packages/DB/mysql.php(328): DB_mysql->mysqlRaiseError()
#8 /Users/rota/Sites/drupal/sites/all/modules/civicrm/packages/DB/common.php(1216): DB_mysql->simpleQuery("SELECT GET_LOCK( 'pincsf.1.cache.CiviCRM setting Specs_settingsMetadata___nam...")
#9 /Users/rota/Sites/drupal/sites/all/modules/civicrm/packages/DB/DataObject.php(2442): DB_common->query("SELECT GET_LOCK( 'pincsf.1.cache.CiviCRM setting Specs_settingsMetadata___nam...")
#10 /Users/rota/Sites/drupal/sites/all/modules/civicrm/packages/DB/DataObject.php(1634): DB_DataObject->_query("SELECT GET_LOCK( 'pincsf.1.cache.CiviCRM setting Specs_settingsMetadata___nam...")
#11 /Users/rota/Sites/drupal/sites/all/modules/civicrm/CRM/Core/DAO.php(325): DB_DataObject->query("SELECT GET_LOCK( 'pincsf.1.cache.CiviCRM setting Specs_settingsMetadata___nam...")
#12 /Users/rota/Sites/drupal/sites/all/modules/civicrm/CRM/Core/DAO.php(1234): CRM_Core_DAO->query("SELECT GET_LOCK( 'pincsf.1.cache.CiviCRM setting Specs_settingsMetadata___nam...", TRUE)
#13 /Users/rota/Sites/drupal/sites/all/modules/civicrm/CRM/Core/Lock.php(151): CRM_Core_DAO::singleValueQuery("SELECT GET_LOCK( %1, %2 )", (Array:2))
#14 /Users/rota/Sites/drupal/sites/all/modules/civicrm/Civi/Core/Lock/LockManager.php(84): CRM_Core_Lock->acquire(NULL)
#15 /Users/rota/Sites/drupal/sites/all/modules/civicrm/CRM/Core/BAO/Cache.php(154): Civi\Core\Lock\LockManager->acquire("cache.CiviCRM setting Specs_settingsMetadata___name_resCacheCode._")
#16 /Users/rota/Sites/drupal/sites/all/modules/civicrm/CRM/Core/BAO/Setting.php(715): CRM_Core_BAO_Cache::setItem((Array:1), "CiviCRM setting Specs", "settingsMetadata___name_resCacheCode", NULL)
#17 /Users/rota/Sites/drupal/sites/all/modules/civicrm/api/v3/Setting.php(66): CRM_Core_BAO_Setting::getSettingSpecification(NULL, (Array:1), NULL, NULL)
#18 /Users/rota/Sites/drupal/sites/all/modules/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_setting_getfields((Array:2))
#19 /Users/rota/Sites/drupal/sites/all/modules/civicrm/Civi/API/Kernel.php(96): Civi\API\Provider\MagicFunctionProvider->invoke((Array:9))
#20 /Users/rota/Sites/drupal/sites/all/modules/civicrm/api/api.php(23): Civi\API\Kernel->run("setting", "getfields", (Array:2), NULL)
#21 /Users/rota/Sites/drupal/sites/all/modules/civicrm/api/api.php(43): civicrm_api("setting", "getfields", (Array:2))
#22 /Users/rota/Sites/drupal/sites/all/modules/civicrm/CRM/Core/BAO/Setting.php(591): civicrm_api3("setting", "getfields", (Array:2))
#23 /Users/rota/Sites/drupal/sites/all/modules/civicrm/CRM/Core/BAO/Setting.php(382): CRM_Core_BAO_Setting::validateSettingsInput((Array:1), (Array:0))
#24 /Users/rota/Sites/drupal/sites/all/modules/civicrm/CRM/Core/Resources.php(558): CRM_Core_BAO_Setting::setItem("B8kFl", "CiviCRM Preferences", "resCacheCode")
#25 /Users/rota/Sites/drupal/sites/all/modules/civicrm/CRM/Core/Resources.php(567): CRM_Core_Resources->setCacheCode("B8kFl")
#26 /Users/rota/Sites/drupal/sites/all/modules/civicrm/CRM/Core/Resources.php(144): CRM_Core_Resources->resetCacheCode()
#27 /Users/rota/Sites/drupal/sites/all/modules/civicrm/CRM/Core/Resources.php(122): CRM_Core_Resources->__construct(Object(CRM_Extension_Mapper), Object(CRM_Utils_Cache_SqlGroup), "resCacheCode")
#28 /Users/rota/Sites/drupal/sites/all/modules/civicrm/drupal/civicrm.module(48): CRM_Core_Resources::singleton()
#29 /Users/rota/Sites/drupal/sites/all/modules/civicrm/drupal/civicrm.module(223): civicrm_html_head()
#30 /Users/rota/Sites/drupal/sites/all/modules/civicrm/drupal/civicrm.module(103): civicrm_initialize()
#31 [internal function](): civicrm_menu()
#32 /Users/rota/Sites/drupal/includes/menu.inc(2812): call_user_func("civicrm_menu")
#33 /Users/rota/Sites/drupal/includes/menu.inc(2775): menu_router_build()
#34 /Users/rota/Sites/drupal/sites/all/modules/civicrm/drupal/civicrm.module(788): menu_rebuild()
#35 [internal function](): civicrm_enable()
#36 /Users/rota/Sites/drupal/includes/module.inc(905): call_user_func_array("civicrm_enable", (Array:0))
#37 /Users/rota/Sites/drupal/includes/module.inc(484): module_invoke("civicrm", "enable")
#38 /Users/rota/Sites/drupal/sites/all/modules/civicrm/install/index.php(1330): module_enable((Array:2))
#39 /Users/rota/Sites/drupal/sites/all/modules/civicrm/install/index.php(271): Installer->install((Array:5))
#40 {main}

5 Answers 5


Another solution is to upgrade at least to CiviCRM 4.6.16 or to CiviCRM 4.7.7 or you can also patch your installation.

If you are familair with patches you can also download a patch from the civi site. https://github.com/civicrm/civicrm-core/commit/3f7df5902facad68489e225b504a887c2b45eb91.diff and then apply that patch to your civicrm installation.

  • Thank you Jaap. Users can either patch older civi or use the versions you named if they need MySQL >= 5.7. Good news!
    – Tim Renner
    Commented Aug 19, 2016 at 20:09
  • 1
    Had this problem migrating an older site to a new server with MySQL 5.7. Thanks for posting the fix! Commented Apr 30, 2018 at 18:08

Here's a patch that seems to address the issue, although there could still be compatibility issues in the PEAR mysql and mysqli library versions used by CiviCRM.

This patch is for CiviCRM 4.7.4:

diff --git a/civicrm/CRM/Core/Lock.php b/civicrm/CRM/Core/Lock.php
index b594e0b..4643fc4 100644
--- a/civicrm/CRM/Core/Lock.php
+++ b/civicrm/CRM/Core/Lock.php
@@ -121,6 +121,9 @@ class CRM_Core_Lock implements \Civi\Core\Lock\LockInterface {
     else {
       $this->_name = $database . '.' . $domainID . '.' . $name;
+    if (strlen($this->_name) > 64) {
+      $this->_name = sha1( $this->_name );
+    }
     if (defined('CIVICRM_LOCK_DEBUG')) {
       CRM_Core_Error::debug_log_message('trying to construct lock for ' . $this->_name);
  • this looks good to me, what implications might there be of changing the names ? are these only temporary tables ? Commented Aug 11, 2016 at 9:59

Solution, don't upgrade to MySQL 5.7.x until this incompatibility is addressed:

The MDL subsystem imposes a limit of 64 characters on lock names, so this limit now also applies to named locks. Previously, no length limit was enforced.

MySql 5.7 Reference Manual, Changes Affecting Upgrades to MySQL 5.7

  • Well... that's bittersweet. Sounds like MySQL 5.7 is two steps forward (enabling processes to hold multiple locks) and one step back (limiting the name length). If we could ditch MySQL <=5.6, then one could rewrite CRM_Core_Lock to be cleaner and more correct. Alas, we'll have to support both...
    – Tim Otten
    Commented Dec 7, 2015 at 3:00
  • You might be able to work-around by putting this in civicrm.settings.php; define('CIVICRM_CACHE_LOCK', 'CRM_Core_Lock::createGlobalLock'); define('CIVICRM_DATA_LOCK', 'CRM_Core_Lock::createGlobalLock'); define('CIVICRM_WORK_LOCK', 'CRM_Core_Lock::createGlobalLock');
    – Tim Otten
    Commented Dec 7, 2015 at 3:04

You should get a full error message if you turn on debugging go to

Administer menu > System Settings > Debugging and Error Handling, select "Yes" to both "Enable Debugging" and "Display Backtrace", and press "Save"

and then re-try

  • Thanks for the suggestion. I can't get to any civicrm pages.
    – Tim Renner
    Commented Dec 1, 2015 at 18:15
  • I edited the problem description.
    – Tim Renner
    Commented Dec 2, 2015 at 15:33

Check once after deleting the templates_c folder (temporary).


  • Thanks for the suggestion. Deleting civi's templates_c folder didn't fix this.
    – Tim Renner
    Commented Dec 1, 2015 at 18:14
  • Can please check civicrm.settings. php file for database configuration. Also browser console log.
    – Prem Patel
    Commented Dec 1, 2015 at 18:30
  • Also can you paste here the civicrm config log errors.
    – Prem Patel
    Commented Dec 1, 2015 at 18:31
  • Pasted backtrace at end of question.
    – Tim Renner
    Commented Dec 2, 2015 at 4:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.