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

153
Views
SQL user is not used for login

My problem is occuring when I try to login to SQL using user:'root', host: 'localhost', database: 'db' and password: '' ,the console gives error like I didn't define user

[!] SQL Error: Error: ER_ACCESS_DENIED_ERROR: Access denied for user ''@'localhost' (using password: NO)

My server.js:

import SQL from 'mysql';


 SQL: {

      host: 'localhost'
      user: 'root'
      password: ''
      database: 'root'

};


function load() {
    var MySQL = SQL.createConnection(SQL)
    MySQL.connect((err) => {
          if(err) {
             console.log(err);
             process.exit(0);
          }
        
          for(var i = 0; i < 250; i++) console.log("\n");
          console.log('Successfuly logged in!');

    });
    
}
load();

What can be done to prevent this error?

I am new to SQL and JS so please, don't be harsh on me if it's a stupid question :)

EDIT: I want to mention that I tried changing values of host, user, password and database and whatever I put, it says the same error.

I tried setting some random word for pass, example: password: 'pass123' but the console gives me the same error inluding using password: NO part.

What could cause that problem?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Your SQL field isn't a valid object.

Change

SQL: {

      host: 'localhost'
      user: 'root'
      password: ''
      database: 'root'

};

to

credentials = {

      host: 'localhost'
      user: 'root'
      password: ''
      database: 'root'

};
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!