1

I'm creating a NodeJS application running on localhost:3000. I'm also trying to make a mySQL connection on my Synology NAS using the following code:

var mysql = require('mysql');
var connection = mysql.createConnection({
    host     : '192.168.1.17',
    port     : 3306,
    user     : 'root',
    password : 'password'
});

connection.connect( function(err) {
    if (err)
        console.log(err);
    else
        console.log('connected');
});

Unfortunately the console keeps displaying an error.

ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'192.168.1.15'

The strange thing here is that I'm trying to make a connection to my NAS station on 192.168.1.17, but the console says the host is .15. Can someone explain me why?

I've also Googled this issue, but the solution of granting privileges for the root user from this stack topic doesn't seem to work.

Someone can help me out here?

2 Answers 2

2

192.168.1.15 is you, your node app running in your PC, probably you haven't an access list for root@% where % means from anywhere, you only have access list for root@localhost but you aren't on Mysql localhost.

You can add it with this mysql command you have to run on your mysql server:

CREATE USER 'root'@'%' IDENTIFIED BY 'password';
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your reply. I've tried it but I'll get the following error: #1396 - Operation CREATE USER failed for 'root'@'%' . I do suppose I'll have to insert my own password into the identifier? Although I've tried both, but none is working.
I'm using the SQL tab in phpMyAdmin on my server (localhost).
0

I've fixed my problem: It seems that the root user is secured by default.

CREATE USER 'newuser'@'%' IDENTIFIED BY 'choseAPassword';
GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'%';
FLUSH PRIVILEGES;

@Michelem Thanks for the help though ;)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.