Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

375
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!