Can connect from mysql cli, but not from node-mysql2
See original GitHub issueI’ve been getting a “host not allowed to connect error” that completely baffles me, as connecting from the mysql command line interface using the same parameters works fine. I boiled it down to the simplest possible setup for testing:
var mysql = require("mysql2");
var db = mysql.createConnection({
"database": "database",
"user": "user",
"password": "xxxxxxx",
"host": "yyy.yyy.yyy.yyy",
"insecureAuth":true,
"debug":true,
"ssl": {
"rejectUnauthorized":false
}
});
db.connect();
db.query("SELECT * FROM table LIMIT 1", function(err, res) {});
db.end();
The insecureAuth and ssl options were meant to help eliminate server-side issues. The same error occurs with or without them.
Running this with node test.js results in:
0 undefined ==> Connection#handshakeInit(0,Error,70)
raw: ff6a04486f737420273137332e33302e38332e32343927206973206e6f7420616c6c6f77656420746f20636f6e6e65637420746f2074686973204d7953514c20736572766572
events.js:85
throw er; // Unhandled 'error' event
^
Error: Host 'zzz.zzz.zzz.zzz' is not allowed to connect to this MySQL server
at Packet.asError (/home/nphyx/Dropbox/dev/fbradius/node_modules/mysql2/lib/packets/packet.js:493:13)
at ClientHandshake.Command.execute (/home/nphyx/Dropbox/dev/fbradius/node_modules/mysql2/lib/commands/command.js:25:22)
at Connection.handlePacket (/home/nphyx/Dropbox/dev/fbradius/node_modules/mysql2/lib/connection.js:310:28)
at PacketParser.onPacket (/home/nphyx/Dropbox/dev/fbradius/node_modules/mysql2/lib/connection.js:83:65)
at PacketParser.executeStart (/home/nphyx/Dropbox/dev/fbradius/node_modules/mysql2/lib/packet_parser.js:39:12)
at Socket.<anonymous> (/home/nphyx/Dropbox/dev/fbradius/node_modules/mysql2/lib/connection.js:95:31)
at Socket.emit (events.js:107:17)
at readableAddChunk (_stream_readable.js:163:16)
at Socket.Readable.push (_stream_readable.js:126:10)
at TCP.onread (net.js:538:20)
However if I do:
$ mysql -u user -p -h yyy.yyy.yyy.yyy --database database
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 260318
Server version: 5.5.41-MariaDB-log MariaDB Server
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
I connect successfully and am able to run queries per the permissions configured on the mysql server.
The server is not configured to require/use SSL. It is running on the standard (3306) port and listening on the external interface, as the cli results indicate.
Local host info:
$ uname -a
Linux jormungandr 3.19.3-3-ARCH #1 SMP PREEMPT Wed Apr 8 14:10:00 CEST 2015 x86_64 GNU/Linux
$ node --version
v0.12.2
Any thoughts? I’m on a tight deadline here so please let me know if you need anything else.
Issue Analytics
- State:
- Created 8 years ago
- Comments:15 (9 by maintainers)
good
no problems, good luck with the rest!