6

When I trying to install drupal-7 in my server, at the setup database step it shows the error

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'.

The database name, username, and password are all correct.

Is there any solution to this problem?

ronalchn
  • 12,225
  • 10
  • 51
  • 61
user1699120
  • 91
  • 2
  • 4
  • maybe this work: https://stackoverflow.com/questions/50336378/variable-sql-mode-cant-be-set-to-the-value-of-no-auto-create-user – CoTg Feb 09 '22 at 10:04

2 Answers2

0

How have I fixed (Syntax error or access violation: 1231 Variable 'sql_mode' can't be set to the value of 'NO_AUTO_CREATE_USER') problem in laravel

  1. SO go to config/database.php

  2. in mysql connection add the following

  3. code

    'modes' => [ 'ONLY_FULL_GROUP_BY', 'STRICT_TRANS_TABLES', 'NO_ZERO_IN_DATE', 'NO_ZERO_DATE', 'ERROR_FOR_DIVISION_BY_ZERO', 'NO_ENGINE_SUBSTITUTION', ],

The whole connection will be something like the following

'mysql' => [
      'driver' => 'mysql',
      'host' => env('DB_HOST', '127.0.0.1'),
      'port' => env('DB_PORT', '3306'),
      'database' => env('DB_DATABASE', 'forge'),
      'username' => env('DB_USERNAME', 'forge'),
      'password' => env('DB_PASSWORD', ''),
      'unix_socket' => env('DB_SOCKET', ''),
      'charset' => 'utf8mb4',
      'collation' => 'utf8mb4_unicode_ci',
      'prefix' => '',
      'strict' => true,
      'engine' => null,
      'modes'  => [
          'ONLY_FULL_GROUP_BY',
          'STRICT_TRANS_TABLES',
          'NO_ZERO_IN_DATE',
          'NO_ZERO_DATE',
          'ERROR_FOR_DIVISION_BY_ZERO',
          'NO_ENGINE_SUBSTITUTION',
      ],
  ],
-1

Drupal isn't allowed to create a new user in your MySQL database. You need at least MySQL 5.0.15