Strapi TypeError with MySQL2: Cannot set properties of undefined (setting 'supportBigNumbers')

System Information
  • Strapi Version: 4.10.4
  • Operating System: Windows 10
  • Database: MySQL / MySQL2
  • Node Version: v18.15.0
  • NPM Version: v9.5.0
  • Yarn Version: not installed

Hello Strapi Community,

I am currently experiencing a persistent issue when trying to run my Strapi project using MySQL2 as the database client. The error message I receive when running npm run develop is as follows:

TypeError: Cannot set properties of undefined (setting ‘supportBigNumbers’)
at MysqlDialect.configure (D:\Windows\Desktop\Erudita website\backend\node_modules@strapi\database\lib\dialects\mysql\index.js:20:60)
at new Database (D:\Windows\Desktop\Erudita website\backend\node_modules@strapi\database\lib\index.js:32:18)
at Database.init (D:\Windows\Desktop\Erudita website\backend\node_modules@strapi\database\lib\index.js:123:14)
at Strapi.bootstrap (D:\Windows\Desktop\Erudita website\backend\node_modules@strapi\strapi\lib\Strapi.js:420:30)
at Strapi.load (D:\Windows\Desktop\Erudita website\backend\node_modules@strapi\strapi\lib\Strapi.js:491:16)
at async workerProcess (D:\Windows\Desktop\Erudita website\backend\node_modules@strapi\strapi\lib\commands\actions\develop\action.js:110:26)
I initially received this error when using ‘mysql’ as the client, but the error persists after switching to ‘mysql2’.

Here are the steps I have taken so far to resolve the issue:

Checked and verified that I have MySQL2 installed and that the database is correctly configured in my database.js file.
Updated the database.js file to use ‘mysql2’ as the client and to include ‘supportBigNumbers’ and ‘bigNumberStrings’ in the ‘options’.
Reinstalled MySQL and recreated the necessary databases.
Tried removing ‘supportBigNumbers’ and ‘bigNumberStrings’ from the options.
Despite these efforts, the error remains. I’m currently using the latest version of Strapi and MySQL2. I’ve also reinstalled my node modules and ensured that my environment variables are correctly set.

Databases.js looks like this:
const path = require(‘path’);

module.exports = ({ env }) => {

const client = env(‘DATABASE_CLIENT’, ‘mysql2’);

const connections = {

mysql2: {

  connector: 'bookshelf',

  settings: {

    client: 'mysql2',

    host: env('DATABASE_HOST', 'localhost'),

    port: env.int('DATABASE_PORT', 3306),

    database: env('DATABASE_NAME', 'main'),

    username: env('DATABASE_USERNAME', 'admin'),

    password: env('DATABASE_PASSWORD', '%Erudita!2023.'),

    ssl: env.bool('DATABASE_SSL', false),

  },

  options: {

    useNullAsDefault: true,

  },

  pool: { min: env.int('DATABASE_POOL_MIN', 2), max: env.int('DATABASE_POOL_MAX', 10) },

},

};

return {

connection: {

  client,

  ...connections[client],

  acquireConnectionTimeout: env.int('DATABASE_CONNECTION_TIMEOUT', 60000),
},

};
};

//I’m developing localy and passwords will change when we deploy our website.

Any assistance or insights from the community would be greatly appreciated. Thank you in advance!

I got the same error today when switching DATABASE_CLIENT from mysql to mysql2. Did you figure out a solution?

I solved my issue by changing the key “mysql” to “mysql2” in config/database.js.

Which suggests your problem might be similar, maybe you have still DATABASE_CLIENT setting set to “mysql” instead “mysql2”