Skip to content

ER_ACCESS_DENIED_ERROR to local mysql database after updating to v4.12.1 #1825

@luboslives

Description

@luboslives

Bug report

Required System information

  • Node.js version: 18.14.0
  • NPM version: 9.8.1
  • Strapi version: 4.12.1
  • Database: "mariadb from 11.0.2-MariaDB, client 15.2 for osx10.14 (x86_64) using EditLine wrapper"
  • Operating system: macOS Mojave 10.14.6
  • Is your project Javascript or Typescript: JS

Describe the bug

Looking to see if anyone else has this problem – I upgraded to Strapi 4.12.1, npm install had no problems, npm run build had no problems, but npm run develop will run into this error:

> strapi develop

Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'user'@'localhost' (using password: YES)
    at Sequence._packetToError (/projectdir/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
    at Handshake.ErrorPacket (/projectdir/node_modules/mysql/lib/protocol/sequences/Handshake.js:123:18)
    at Protocol._parsePacket (/projectdir/node_modules/mysql/lib/protocol/Protocol.js:291:23)
    at Parser._parsePacket (/projectdir/node_modules/mysql/lib/protocol/Parser.js:433:10)
    at Parser.write (/projectdir/node_modules/mysql/lib/protocol/Parser.js:43:10)
    at Protocol.write (/projectdir/node_modules/mysql/lib/protocol/Protocol.js:38:16)
    at Socket.<anonymous> (/projectdir/node_modules/mysql/lib/Connection.js:88:28)
    at Socket.<anonymous> (/projectdir/node_modules/mysql/lib/Connection.js:526:10)
    at Socket.emit (node:events:513:28)
    at Socket.emit (node:domain:489:12)
    --------------------
    at Protocol._enqueue (/projectdir/node_modules/mysql/lib/protocol/Protocol.js:144:48)
    at Protocol.handshake (/projectdir/node_modules/mysql/lib/protocol/Protocol.js:51:23)
    at Connection.connect (/projectdir/node_modules/mysql/lib/Connection.js:116:18)
    at /projectdir/node_modules/knex/lib/dialects/mysql/index.js:66:18
    at new Promise (<anonymous>)
    at Client_MySQL.acquireRawConnection (/projectdir/node_modules/knex/lib/dialects/mysql/index.js:61:12)
    at create (/projectdir/node_modules/knex/lib/client.js:262:39) {
  code: 'ER_ACCESS_DENIED_ERROR',
  errno: 1045,
  sqlMessage: "Access denied for user 'user'@'localhost' (using password: YES)",
  sqlState: '28000',
  fatal: true
}

Additional context

Now, I had a look at .env and everything looks correct. I thought maybe the problem was that the local SQL server is running in a socket – so I tried to add a socketPath to config/database.js, as suggested in this old thread: strapi/strapi#1714 but the error persists.

As an aside, there is nothing in the docs about connecting to a database using a socket, only the port. Now I don't know why my local SQL db would have switched to a socket on its own – I'm assuming it was running like that all along and Strapi did not have a problem connecting to it until the update to v4.12.1

MariaDB had to be built as there was no prebuild available for my system in homebrew - maybe that plays a factor here, if nothing else can be found.

Metadata

Metadata

Assignees

Labels

issue: docs/instructionsIssues about incorrect instructions found on docs.strapi.io

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions