Hi,

I am trying to install and configure DRUPAL on a WIN 2008 Server.
This is the first time we are trying to install and configure DRUPAL.
While configuring the database connection we are getting the following error.

SQLSTATE[42000]: Syntax error or access violation: 1231 Variable 'sql_mode' can't be set to the value of 'NO_AUTO_CREATE_USER'.

Resolve all issues below to continue the installation. For help configuring your database server, see the installation handbook, or contact your hosting provider.
•Failed to connect to your database server. The server reports the following message: SQLSTATE[42000]: Syntax error or access violation: 1231 Variable 'sql_mode' can't be set to the value of 'NO_AUTO_CREATE_USER'.
•Is the database server running? ---- YES
•Does the database exist or does the database user have sufficient privileges to create the database? ---- YES
•Have you entered the correct database name? ---- YES
•Have you entered the correct username and password? ---- YES
•Have you entered the correct database hostname? ---- YES

I have granted the user DBA privileges and am able to connect to the database using workbench.

The following are the versions we are using
Drupal – 8.5.3
MySQL – 8.0
PHP – 7.2.2

I have commented out the sql_mode in my.ini file, still we are getting the same error.
Any help in guiding us resolve this issue is much appreciated. Thanks.

Comments

scarecr0w created an issue. See original summary.

cilefen’s picture

Status: Active » Fixed
Related issues: +#2966523: MySQL 8 Support

Support for MySQL 8 isn't there yet. There's a small patch on that other issue you could try. But for the best possible experience, use MySQL 5.7 unless you are comfortable experimenting.

cilefen’s picture

Title: Drupal configuration issue with MySQL » MySQL 8 is not yet supported: SQLSTATE[42000]: Syntax error or access violation: 1231 Variable 'sql_mode' can't be set to the value of 'NO_AUTO_CREATE_USER'.
Issue tags: -NO_AUTO_CREATE_USER

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

phannphong’s picture

I have the same problem when using MySQL Ver 8.0.13.
Who can support this?

cilefen’s picture

ferrete’s picture

Any news about the conflict with MySQL 8?

mmjvb’s picture

Conflict should be resolved:

    452     // NO_AUTO_CREATE_USER is removed in MySQL 8.0.11
    453     // https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-11.html#mysqld-8-0-11-deprecation-removal
    454     $version_server = $pdo->getAttribute(\PDO::ATTR_SERVER_VERSION);
    455     if (version_compare($version_server, '8.0.11', '<')) {
    456       $sql_mode .= ',NO_AUTO_CREATE_USER';
    457     }
vensires’s picture

The issue should be actually solved for Drupal 8 according to #8.

Google returns this page as a first result even for Drupal 7 searches though so - in that case - you could use the following workaround:
1. Go to your settings.php file.
2. Go to your database settings array.
3. Make sure its init_commands matches the following:

$databases = array (
  'default' => array (
    'default' =>  array (
      'database' => '',
      'username' => '',
      'password' => '',
      'host' => 'localhost',
      'port' => '3306',
      'driver' => 'mysql',
      'prefix' => '',
      'init_commands' => array(
        'sql_mode' => "SET 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'",
      )
    ),
  ),
);

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

lakshmi_a’s picture

@vensires
Thank you it's working for me.

mmjvb’s picture

For Drupal 7 see #2978575: Mysql 8 Support on Drupal 7
It is still WIP, patch #24 should get you started. Consider D8 solution better regarding sql_mode. Recommend changing the code rather than overriding with settings.php

dangolk’s picture

@lakshmi_a Yes, just confirmed that solution from @venisires worked on my local instance too! (MySQL 8.0.19 - Homebrew, Apache/2.4.41(Unix), PHP/7.3.11)

Thank you @venisires!!a

mkrkarthi’s picture

Version: 8.5.3 » 10.0.x-dev

This is working on Ubuntu 20.04 where default MySQL 8.0.20 & PHP 7.4
thank you

sreenivas bttv’s picture

#9 working perfectly.

sajt’s picture

@vensires #10 perfect solution for me. Lifesaving.

vensires’s picture

Version: 10.0.x-dev » 8.5.x-dev
Related issues: +#2978575: Mysql 8 Support on Drupal 7

Reverting the previous (I suppose accidental) version change since according to #2966523: MySQL 8 Support this issue is fixed in Drupal 8.6+.

Also set #2978575: Mysql 8 Support on Drupal 7 as a related issue to allow users coming here from search results to use the patch proposed there, hoping it will land to Drupal 7.x.

heni_deepak’s picture

#9 is the perfect solution.

mmjvb’s picture

No, #9 is not the perfect solution. This issue is already fixed, proper solution is implemented.

The workaround in #9 can be used in older versions that don't have a solution as it is not back ported.

This issue should probably have been closed as duplicate and for 8.6-dev as the solution is not provided here and fixed in 8.6.

Taimur_Ahmed’s picture

#9 working perfectly for drupal 8.3

jaspm2004’s picture

#9 did it! thanks!

minamina’s picture

Merci a versires, version drupal 7.59