Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

376
Visualizações
mySQL/Node error message: 'Ignoring invalid configuration option passed to Connection: username'

I'm building an employee tracker application using node and mysql and I keep getting this error when I run my code in the command line: 'Ignoring invalid configuration option passed to Connection: username. This message is currently a warning, but in future versions of MYSQL2, an error will be thrown if you pass an invalid configuration option to a Connection'

This is my code in JS for the connection. My password is in an .env file

// Connects to database + .env for password privacy
const connection = mysql.createConnection({
    host: "localhost",
    username: "root",
    password: process.env.DB_PASS,
    port: PORT,
    database: "employee_tracker",
    }
);

connection.connect((err) => {
    if (err) {
        console.log("Error with connection")
    } else {
        console.log("Connected to Employee Tracker")
    }
    // Calls Starting Fx that begins program
    init();
})

app.listen(PORT, () =>
  console.info(`Example app listening at http://localhost:${PORT}`)
);

I'm not really sure what I'm doing wrong. Per a previous stack overflow answer, I attempted to change my username to 'user' with no success. Any help appreciated. Thanks!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The correct key is user not username see docs

const connection = mysql.createConnection({
    host: 'localhost',
    user: 'root',
    password: process.env.DB_PASS,
    port: process.env.DB_PORT || 3306,
    database: 'employee_tracker',
    }
);

Also, you have defined port which I'm not certain is supported option in MYSQL2 but is in mysqljs/mysql. However, you currently have it set to a variable PORT which you are also using as a variable for the port your app will listen on. Both services can not run on the same port. I've updated my example accordingly but you should review and do something similar.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda