Mysql: host is ignored when I have a dot in it

Created on 24 Nov 2016  路  3Comments  路  Source: mysqljs/mysql

Hi,

I'm trying to get a connection to a server but it sends the login credendtials with the wrong host as soon as host contains a '.' in it and falls back to localhost

so when I try this:

var db = mysql.createConnection({
user: 'web84_9',
password: 'MyPassword',
host: 'server5.webgo24.de',
database: 'web84_db9',
debug: 'true',
});
db.connect(function(err) {
if (err) {
console.error('error connecting: ' + err.stack);
return;
}

console.log('connected as id ' + connection.threadId);
});

I get

message: 'Access denied for user \'web84_9\'@\'rasalhague.uberspace.de\' (using password: YES)' }

(rasalhague.uberspace.de is the local host name)

and when I change the host to something like "server5" i get the expected confused message.
It shows \'web84_9\'@\'localhost\' when I change the host to localhost

I want to login as [email protected] ... I don't know if this is a bug or not or how to do it, maybe I'm missing some fundamental knowledge about MySQL... If so pls explain :-)

question

Most helpful comment

Hi @Rhapsody-Sky I think you're misunderstanding how MySQL grants work. For example, the error you're getting Access denied for user 'web84_9'@'rasalhague.uberspace.de' (using password: YES) is being generated by your MySQL server, not this module. The format is '<username>'@'<machine_you_connected_from>'. By default MySQL server will do a reverse DNS lookup of the IP address the connection came from and put that DNS name there if there is one. rasalhague.uberspace.de should be the name of the machine you connected from, not the name of the MySQL server, for how MySQL server works.

I hope this helps.

All 3 comments

Try adding 'https://' to your host
ie host: 'https://server5.webgo24.de',

I tried it but now I get

getaddrinfo ENOTFOUND https://server5.webgo24.de https://server5.webgo24.de:3306

Hi @Rhapsody-Sky I think you're misunderstanding how MySQL grants work. For example, the error you're getting Access denied for user 'web84_9'@'rasalhague.uberspace.de' (using password: YES) is being generated by your MySQL server, not this module. The format is '<username>'@'<machine_you_connected_from>'. By default MySQL server will do a reverse DNS lookup of the IP address the connection came from and put that DNS name there if there is one. rasalhague.uberspace.de should be the name of the machine you connected from, not the name of the MySQL server, for how MySQL server works.

I hope this helps.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

johnrc picture johnrc  路  3Comments

EdoardoPedrotti picture EdoardoPedrotti  路  3Comments

tbaustin picture tbaustin  路  3Comments

DmitryEfimenko picture DmitryEfimenko  路  4Comments

skilbjo picture skilbjo  路  3Comments