Olá. Estou tendo um erro na conexão com o mySQL. Eu já tive de substituir a instalação para o mysql2, como algumas recomendações aqui no fórum.
Erro:
Error: Access denied for user 'root'@'localhost' (using password: YES)
at Packet.asError (C:\Users\cassi\Desktop\Estudos Alura\Cursos Alura\Rest com NodeJS API com Express e MySQL\node_modules\mysql2\lib\packets\packet.js:722:17)
at ClientHandshake.execute (C:\Users\cassi\Desktop\Estudos Alura\Cursos Alura\Rest com NodeJS API com Express e MySQL\node_modules\mysql2\lib\commands\command.js:28:26)
at Connection.handlePacket (C:\Users\cassi\Desktop\Estudos Alura\Cursos Alura\Rest com NodeJS API com Express e MySQL\node_modules\mysql2\lib\connection.js:456:32)
at PacketParser.onPacket (C:\Users\cassi\Desktop\Estudos Alura\Cursos Alura\Rest com NodeJS API com Express e MySQL\node_modules\mysql2\lib\connection.js:85:12)
at PacketParser.executeStart (C:\Users\cassi\Desktop\Estudos Alura\Cursos Alura\Rest com NodeJS API com Express e MySQL\node_modules\mysql2\lib\packet_parser.js:75:16)
at Socket.<anonymous> (C:\Users\cassi\Desktop\Estudos Alura\Cursos Alura\Rest com NodeJS API com Express e MySQL\node_modules\mysql2\lib\connection.js:92: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 'root'@'localhost' (using password: YES)",
sql: undefined
conexao.js:
const mysql = require('mysql2')
const conexao = mysql.createConnection({
host: 'localhost',
port: 3306,
user: 'root',
password: 'admin',
database: 'agenda-petshop'
})
module.exports = conexao
index.js:
const customExpress = require('./config/customExpress')
const conexao = require('./infraestrutura/conexao')
conexao.connect(erro => {
if(erro) {
console.log(erro)
} else {
const app = customExpress()
app.listen(3000, () => console.log('servidor rodando na porta 3000'))
console.log('oi')
}
})