module MySQL nodejs

I have a problem with the mysql module this is is my part of code for testing connection :

var express = require('express');
var mysql = require('mysql');
var fs = require('fs');

var app = express()
  , http = require('http')
  , server = http.createServer(app)
  , io = require('socket.io').listen(server);

io.sockets.on('connection', function(socket){

// en connection :

socket.on('info', function (host,user,mdp,mdp1) {
var connection = mysql.createConnection(
    {
      host     : host,
      user     : user,
      password : mdp,
      database : '',
    }
);
        connection.connect(function(err) {
          if (err) {
                     console.log('Erreur de connexion au serveur');
                     socket.emit('erreur','err');
                   } 
          else {

            socket.emit('succes',host,user,mdp);

                       }
           });

  });

if there an error of connection I will emit a message in order to display a message of error. else I will display message of success.

  • my host is : localhost
  • user : root
  • password : ''

  • if I enter localhost and root the message is "Test OK"
  • if I enter localhostfalse and rootfalse the message is "Test No" ( it's normal)
  • if I enter localhost and rootfalse the message is "TestOk".

so why there's no test for ' root'

I wish my problem is understood. Thanks

Could it be that your database configuration accepts any user?