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?

Community
  • 1
  • 1
ronnyrr
  • 1,481
  • 3
  • 26
  • 45

2 Answers2

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';
michelem
  • 14,430
  • 5
  • 50
  • 66
  • 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. – ronnyrr Dec 08 '15 at 11:31
  • I'm using the SQL tab in phpMyAdmin on my server (localhost). – ronnyrr Dec 08 '15 at 11:56
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 ;)

ronnyrr
  • 1,481
  • 3
  • 26
  • 45