Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

377
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda