1
resposta

Access denied

quando executo o comando "node api/banco-de-dados/criarTabelas.js" ele me retorna o erro num 1045 access denied! Como faço para resolver?

segue o log:

AccessDeniedError [SequelizeAccessDeniedError]: Access denied for user 'admin'@'DESKTOP-RF31C74' (using password: NO)
    at ConnectionManager.connect (C:\Users\Éfi\OneDrive\Área de Trabalho\alura\node\api-carwash\node_modules\sequelize\lib\dialects\mysql\connection-manager.js:118:17)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async ConnectionManager._connect (C:\Users\Éfi\OneDrive\Área de Trabalho\alura\node\api-carwash\node_modules\sequelize\lib\dialects\abstract\connection-manager.js:318:24)    
    at async C:\Users\Éfi\OneDrive\Área de Trabalho\alura\node\api-carwash\node_modules\sequelize\lib\dialects\abstract\connection-manager.js:250:32
    at async ConnectionManager.getConnection (C:\Users\Éfi\OneDrive\Área de Trabalho\alura\node\api-carwash\node_modules\sequelize\lib\dialects\abstract\connection-manager.js:280:7)    at async C:\Users\Éfi\OneDrive\Área de Trabalho\alura\node\api-carwash\node_modules\sequelize\lib\sequelize.js:613:26
    at async MySQLQueryInterface.createTable (C:\Users\Éfi\OneDrive\Área de Trabalho\alura\node\api-carwash\node_modules\sequelize\lib\dialects\abstract\query-interface.js:225:12)  
    at async Function.sync (C:\Users\Éfi\OneDrive\Área de Trabalho\alura\node\api-carwash\node_modules\sequelize\lib\model.js:1300:5) {
  parent: Error: Access denied for user 'admin'@'DESKTOP-RF31C74' (using password: NO)
      at Packet.asError (C:\Users\Éfi\OneDrive\Área de Trabalho\alura\node\api-carwash\node_modules\mysql2\lib\packets\packet.js:712:17)
      at ClientHandshake.execute (C:\Users\Éfi\OneDrive\Área de Trabalho\alura\node\api-carwash\node_modules\mysql2\lib\commands\command.js:28:26)
      at Connection.handlePacket (C:\Users\Éfi\OneDrive\Área de Trabalho\alura\node\api-carwash\node_modules\mysql2\lib\connection.js:425:32)
      at PacketParser.onPacket (C:\Users\Éfi\OneDrive\Área de Trabalho\alura\node\api-carwash\node_modules\mysql2\lib\connection.js:75:12)
      at PacketParser.executeStart (C:\Users\Éfi\OneDrive\Área de Trabalho\alura\node\api-carwash\node_modules\mysql2\lib\packet_parser.js:75:16)
      at Socket.<anonymous> (C:\Users\Éfi\OneDrive\Área de Trabalho\alura\node\api-carwash\node_modules\mysql2\lib\connection.js:82:25)
      at Socket.emit (events.js:375:28)
      at addChunk (internal/streams/readable.js:290:12)
      at readableAddChunk (internal/streams/readable.js:265:9)
      at Socket.Readable.push (internal/streams/readable.js:204:10) {
    code: 'ER_ACCESS_DENIED_ERROR',
    errno: 1045,
    sqlState: '28000',
    sqlMessage: "Access denied for user 'admin'@'DESKTOP-RF31C74' (using password: NO)"
  },
  original: Error: Access denied for user 'admin'@'DESKTOP-RF31C74' (using password: NO)
      at Packet.asError (C:\Users\Éfi\OneDrive\Área de Trabalho\alura\node\api-carwash\node_modules\mysql2\lib\packets\packet.js:712:17)
      at ClientHandshake.execute (C:\Users\Éfi\OneDrive\Área de Trabalho\alura\node\api-carwash\node_modules\mysql2\lib\commands\command.js:28:26)
      at Connection.handlePacket (C:\Users\Éfi\OneDrive\Área de Trabalho\alura\node\api-carwash\node_modules\mysql2\lib\connection.js:425:32)
      at PacketParser.onPacket (C:\Users\Éfi\OneDrive\Área de Trabalho\alura\node\api-carwash\node_modules\mysql2\lib\connection.js:75:12)
      at PacketParser.executeStart (C:\Users\Éfi\OneDrive\Área de Trabalho\alura\node\api-carwash\node_modules\mysql2\lib\packet_parser.js:75:16)
      at Socket.<anonymous> (C:\Users\Éfi\OneDrive\Área de Trabalho\alura\node\api-carwash\node_modules\mysql2\lib\connection.js:82:25)
      at Socket.emit (events.js:375:28)
      at addChunk (internal/streams/readable.js:290:12)
      at readableAddChunk (internal/streams/readable.js:265:9)
      at Socket.Readable.push (internal/streams/readable.js:204:10) {
    code: 'ER_ACCESS_DENIED_ERROR',
    errno: 1045,
    sqlState: '28000',
    sqlMessage: "Access denied for user 'admin'@'DESKTOP-RF31C74' (using password: NO)"
  }
}
1 resposta

Sua api está com problema na conexão com o banco de dados. Olhando aqui me parece que seu admin esta errado. Você pode consultar seu admin na propria workbench do Mysql na home. Por exemplo o meu é root e acesso o banco de dados pela porta 3306. Essas são as configs padrão. Pode ser tambem a senha. Da uma olhadinha nesse link. https://pt.stackoverflow.com/questions/70151/erro-access-denied-for-user-rootlocalhost-using-passwordno-ao-aceder-a

Usuário=root / conexao=localhost