Drupal MySQL ‘NO_AUTO_CREATE_USER’ error after upgrading to MySQL version 8


On some outdated Drupal 7 installations, and after a server has been upgraded to MySQL version 8, some websites might stop working displaying the error below:

The website encountered an unexpected error. Please try again later.
Error messagePDOException: SQLSTATE[42000]: Syntax error or access violation: 1231 Variable 'sql_mode' can't be set to the value of 'NO_AUTO_CREATE_USER' in lock_may_be_available() (line 167 of /home/user/public_html/includes/lock.inc).


Some older versions of Drupal are not compatible with MySQL version 8.

To solve this issue, add the following to Drupal’s database initialization array:

'init_commands' => array(

The extra configuration has to be added $databases default section in:


The precise location can be seen in the reference below, but basically add it under 'prefix', or where ever the last section ends.

Why this fix works

The sql_mode directive above contains all the values set by Drupal 7 except NO_AUTO_CREATE_USER


See post #9 here:

Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top