• Register
0 votes
1.4k views

Problem :

I am new to NodeJS and trying to connect to mySQL through the NodeJS file, however I am facing the below error :

{ Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password: YES)

at Handshake.Sequence._packetToError (/home/alecxe/Node/mySqlTest/node_modules/mysql/lib/protocol/sequences/Sequence.js:40:14)

at Handshake.ErrorPacket (/home/alecxe/Node/mySqlTest/node_modules/mysql/lib/protocol/sequences/Handshake.js:77:18)

at Protocol._parsePacket (/home/alecxe/Node/mySqlTest/node_modules/mysql/lib/protocol/Protocol.js:297:24)

at Parser.write (/home/alecxe/Node/mySqlTest/node_modules/mysql/lib/protocol/Parser.js:72:12)

at Protocol.write (/home/alecxe/Node/mySqlTest/node_modules/mysql/lib/protocol/Protocol.js:47:16)

at Socket.ondata (_stream_readable.js:655:20)

at emitOne (events.js:201:20)

at Socket.emit (events.js:288:7)

at readableAddChunk (_stream_readable.js:276:18)

at Socket.Readable.push (_stream_readable.js:234:10)

    --------------------

at Protocol._enqueue (/home/alecxe/Node/mySqlTest/node_modules/mysql/lib/protocol/Protocol.js:210:26)

at Protocol.handshake (/home/alecxe/Node/mySqlTest/node_modules/mysql/lib/protocol/Protocol.js:52:41)

at Connection.connect (/home/alecxe/Node/mySqlTest/node_modules/mysql/lib/Connection.js:91:18)

at Connection._implyConnect (/home/alecxe/Node/mySqlTest/node_modules/mysql/lib/Connection.js:322:10)

at Connection.query (/home/alecxe/Node/mySqlTest/node_modules/mysql/lib/Connection.js:237:8)

at Object.<anonymous> (/home/alecxe/Node/mySqlTest/index.js:21:12)

at Module._compile (module.js:670:32)

at Object.Module._extensions..js (module.js:679:10)

at Module.load (module.js:587:32)

at tryModuleLoad (module.js:546:12)

code: 'ER_ACCESS_DENIED_ERROR',

errno: 1045,

sqlState: '28000',

fatal: true }

I am facing this error when running my javascript. I am using MySQL 5.7.16 on my Ubuntu 16.04.1 on a VM. Not sure if my VM makes a difference here.

Please find below my Javascript code :

'use strict';                                                                                        var mytestsql = require('mytestsql');

var myconnection = mytestsql.createConnection({

host: 'localhost',

user: 'root',

password: 'password'

});

myconnection.query(

'SELECT "foo" AS first_field, "bar" AS second_field',

    function(err, results, fields) {

        console.log(err);

        console.log(results);

        myconnection.end();

    }

);

 

6 5 3
7,540 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

I had faced the same issue, I fixed it by changing the just the password to empty string as follows:

var mytestsql = require('mytestsql');
var myconnection = mytestsql.createConnection({
    host: 'localhost',
    user: 'root',
    password: ''
});

 

9 7 4
38,600 points

Related questions

0 votes
1 answer 23 views
0 votes
1 answer 82 views
82 views
Problem : I am new to MySql. The problem started when I was unable to login to Mysql using my Mysql console. It is repeatedly asking me the password and now I am unable to remember my password. Can I change my password ? And now when I am trying to open my PhpMyAdmin ... WAMP and after that deleted all my related files and then reinstalled it .But it did not fix my issue. How can I fix the issue ?
asked Feb 26, 2020 mphil 2.3k points
0 votes
1 answer 82 views
0 votes
1 answer 73 views
0 votes
1 answer 43 views
43 views
Problem: I had installed MySQL on my linux server sometimes back now I forgot the password so I tried to change it using the ways I found online. What I did was as shown below: /etc/init.d/mysql stop mysqld_safe --skip-grant-tables & mysql --user root mysql SELECT * ... it still shows me below errors  "Access denied for user 'root'@'localhost' (using password: Yes)". How to fix above MYSql error?
asked Jul 14, 2020 Raphael Pacheco 4.9k points
1 vote
1 answer 494 views
494 views
Problem : I am na&iuml;ve to mysql. Currently I am continuously facing below error. &ldquo;Mysql access denied for user 'root'@'localhost' (using password yes)&rdquo;. I have recently started using mySQL Workbench and after doing research on above error I found that my root's ... of no us. I want to get my root access back as soon as possible. Can somebody help me in getting my root access back?
asked Apr 7, 2020 morrisBson 3.2k points
0 votes
2 answers 776 views
776 views
Problem : Whenever I want to open a mysql in my windows cmd by simply typing mysql. I am facing below error : &ldquo;ERROR 1045 (28000): Access denied for user ODBC@localhost (using password: NO)&rdquo; After that by looking at similar queries I somehow got the ... password=root ERROR 1045 (28000): Access denied for user 'admin'@'localhost' (using password:NO) Any pointers will be the great help.
asked Dec 18, 2019 alecxe 7.5k points
0 votes
1 answer 605 views
605 views
Problem : I have recently installed Ubuntu 16.04 and installed web server on it. Everything works well, but I am unable to access database. Even if I create new user and grant all privileges, I can't create database In PHP I am getting below error: SQLSTATE[HY000] [1698] ... ", $this->myname, $this->mypass, self::$mysettings);     } catch (PDOException $e) {         echo $e->getMessage();     } }
asked Jan 17, 2020 jwilliam 3.9k points
0 votes
2 answers 3.7K views
3.7K views
Problem : I keep getting a below error with mysql connection through a XAMPP and I really don't know what to do: &ldquo;Mysqli_real_connect(): (hy000/1045): access denied for user 'pma'@'localhost' (using password: no)&rdquo; I have already reset my password from a MySql from a ... a changes to my code and to my php.ini file, but at each time it goes back to a error. Any help on this issue?
asked Jan 31, 2020 jwilliam 3.9k points
0 votes
1 answer 356 views
356 views
Problem : I am currently using the Mac OS Yosemite and Laravel 5.0. I am new to Laravel 5.0. In the local environment whenever I run the below command php artisan migrate I always encounter below error : &ldquo;Access denied for user 'homestead'@'localhost' (using password: YES)&rdquo; I am unable to fix above error. Any clue to fix the above error?
asked Feb 13, 2020 mphil 2.3k points