By Greg Nowak
If your Drupal 7 site starts returning SQLSTATE[42000] after a move to MySQL 8 and the error names NO_AUTO_CREATE_USER, something is asking MySQL to use an obsolete SQL mode. The fix depends on where it fails. A site that goes down on its first request needs a different repair from a database import that stops halfway through.
Start with the first failing step. If you’re coordinating a hosting provider and an agency, give both teams the exact error and when it appeared. That helps the right team check its part of the deployment before anyone changes production.
Find where NO_AUTO_CREATE_USER is set
MySQL removed NO_AUTO_CREATE_USER in 8.0.11. Old server option files can prevent MySQL from starting, and older database dumps can carry the mode in stored program definitions. Drupal can also request it when it opens a connection. MySQL 8.0 upgrade documentation
| Where it fails | What to check | What to do |
|---|---|---|
| MySQL startup | Server logs, my.cnf and included option files |
Remove the obsolete mode from the active server configuration. |
| SQL import | The failing statement in the dump, including stored program definitions | Correct the relevant mode list in a copy of the dump and retry in a clean staging database. |
| Drupal’s first database connection | Deployed core, the active settings.php and any files it loads |
Verify the core version and check custom connection settings for the old mode. |
| Drupal behind a proxy or managed endpoint | The server version reported to PHP’s PDO driver | Compare it with the actual server version before adding a Drupal session override. |
From the deployed Drupal document root, check the core version and look for connection settings. On a multisite installation, confirm which site directory serves the affected domain.
grep -n "define('VERSION'" includes/bootstrap.inc
grep -RInE 'NO_AUTO_CREATE_USER|sql_mode|init_commands' sites includesA match in core may be part of a version check. Inspect the surrounding code and any deployment-managed settings loaded from outside these directories. Then connect to the database using the same endpoint Drupal uses and run these read-only checks:
SELECT VERSION();
SELECT @@GLOBAL.sql_mode;
SELECT @@SESSION.sql_mode;The session value belongs to the connection that ran the query. A standalone MySQL client gives you a baseline. Once Drupal can connect, run the session query through Drupal as well to see what its initialization commands actually applied.
Fix the setting at its source
Before changing production, take a fresh database backup and save the deployed code and configuration. Rehearse the change on a restored copy, ideally with the same PHP runtime and database connection path. Agree who can call a rollback and how you’ll handle any orders, submissions or edits written after cutover.
If a server option file or a dump contains the old mode, remove that entry from the relevant sql_mode list and retain the other modes. If a custom Drupal connection setting contains it, make the same targeted edit there. Save the change in the template or repository that supplies the setting so the next deployment carries the fix.
If the site predates Drupal 7.76, check for local core modifications before planning an update. Drupal 7.76 changed how the driver sets SQL mode and added quoting for reserved table names such as system. Drupal 7.77 fixed a follow-on issue for table prefixes containing dots, so test any cross-database table sharing. Use the final community release, 7.103, as a historical reference when comparing code. If you have commercial extended support, follow your provider’s update procedure. Drupal’s MySQL 8 change record, Drupal 7.77 release notes, Drupal 7.103 release notes
When a settings.php override makes sense
If core already includes the MySQL 8 changes and PHP’s PDO connection reports a version below 8.0.11 for a newer server, Drupal can still choose the old mode list. If the host can’t correct the version reporting promptly, test this connection-level override. Put it after the affected connection definition in settings.php and adjust the array keys if your site uses a different connection. Drupal’s guidance for misreported MySQL versions
$databases['default']['default']['init_commands']['sql_mode'] =
"SET SESSION sql_mode = 'REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO'";This sets one named initialization command and preserves the others. It replaces the mode list for that Drupal session, so compare it with any existing site-specific list before applying it. Keep strict modes and identifier quoting in place. Record why the override exists and review it when the host fixes version reporting.
Verify the work the site needs to do
Once the homepage loads, sign in as an editor, save a content change, clear caches and run cron. Then test the journeys your business depends on. Submit a lead form and confirm it reaches the right inbox or CRM. Run a test checkout through its payment callback or verify that a scheduled export reaches the receiving system. Check the logs after those tests and record the versions, effective session mode, changed files and rollback location.
Give the Drupal 7 site a next step
Drupal 7 community security and compatibility support ended on 5 January 2025. If the site needs to stay online while you plan a migration, give someone responsibility for its maintenance, check which modules and integrations commercial support would cover, and agree when migration discovery starts. Begin with the workflows the replacement needs to preserve, including how staff publish content and how customer data moves between systems. Drupal Association end-of-life and extended support guidance
If you need someone to coordinate the host, developers and people who rely on the site, share the error and what changed with Greg. He can help you scope the recovery and work out what a migration would need to cover. Talk to Greg about your Drupal site
Related on GrN.dk
- How to Check Whether a PHP Constant Is Defined (Without Breaking Production)
- Install a Specific MySQL Version on Ubuntu Without Creating Upgrade Debt
- MySQL Zero-Date Import Errors: A Safer Fix for Legacy Data
Need help with this kind of work?
Talk to Greg about recovering your Drupal site and planning its next move. Get in touch with Greg.