While trying to connect to the DB using the command line works
mysql -u user --port=3344 --host=0.0.0.0 --password=password
the following fails with an error.
var mysql = require('mysql');
var connection = mysql.createConnection({
host: '0.0.0.0',
user: 'user',
password: 'password',
database: 'test',
port: 3344
});
connection.connect()
The error seems to indicate that the connection was tried on localhost while I explicitly used 0.0.0.0 and it might be connected to this mysql bug, that when trying to connect to localhost, mysql ignores the port command.
{ Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'user'@'localhost' (using password: YES)
at Handshake.Sequence._packetToError (/c/Sources/creassist-backend/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
at Handshake.ErrorPacket (/c/Sources/creassist-backend/node_modules/mysql/lib/protocol/sequences/Handshake.js:123:18)
at Protocol._parsePacket (/c/Sources/creassist-backend/node_modules/mysql/lib/protocol/Protocol.js:291:23)
at Parser._parsePacket (/c/Sources/creassist-backend/node_modules/mysql/lib/protocol/Parser.js:433:10)
at Parser.write (/c/Sources/creassist-backend/node_modules/mysql/lib/protocol/Parser.js:43:10)
at Protocol.write (/c/Sources/creassist-backend/node_modules/mysql/lib/protocol/Protocol.js:38:16)
at Socket.<anonymous> (/c/Sources/creassist-backend/node_modules/mysql/lib/Connection.js:91:28)
at Socket.<anonymous> (/c/Sources/creassist-backend/node_modules/mysql/lib/Connection.js:522:10)
at Socket.emit (events.js:193:13)
at Socket.EventEmitter.emit (domain.js:504:23)
--------------------
at Protocol._enqueue (/c/Sources/creassist-backend/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at Protocol.handshake (/c/Sources/creassist-backend/node_modules/mysql/lib/protocol/Protocol.js:51:23)
at Connection.connect (/c/Sources/creassist-backend/node_modules/mysql/lib/Connection.js:119:18)
at repl:1:12
at Script.runInThisContext (vm.js:124:20)
at REPLServer.defaultEval (repl.js:325:29)
at bound (domain.js:425:14)
at REPLServer.runBound [as eval] (domain.js:438:12)
at REPLServer.onLine (repl.js:650:10)
at REPLServer.emit (events.js:198:15)
code: 'ER_ACCESS_DENIED_ERROR',
errno: 1045,
sqlMessage:
"Access denied for user 'user'@'localhost' (using password: YES)",
sqlState: '28000',
fatal: true,
domainEmitter:
Connection {
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
config:
ConnectionConfig {
host: '0.0.0.0',
port: 3344,
localAddress: undefined,
socketPath: undefined,
user: 'user',
password: 'password',
database: 'test',
connectTimeout: 10000,
insecureAuth: false,
supportBigNumbers: false,
bigNumberStrings: false,
dateStrings: false,
debug: undefined,
trace: true,
stringifyObjects: false,
timezone: 'local',
flags: '',
queryFormat: undefined,
pool: undefined,
ssl: false,
multipleStatements: false,
typeCast: true,
maxPacketSize: 0,
charsetNumber: 33,
clientFlags: 455631,
protocol41: true },
_socket:
Socket {
connecting: false,
_hadError: false,
_parent: null,
_host: null,
_readableState: [ReadableState],
readable: true,
_events: [Object],
_eventsCount: 4,
_maxListeners: undefined,
_writableState: [WritableState],
writable: true,
allowHalfOpen: false,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: null,
_server: null,
timeout: 0,
[Symbol(asyncId)]: 312,
[Symbol(kHandle)]: [TCP],
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]:
Timeout {
_idleTimeout: -1,
_idlePrev: null,
_idleNext: null,
_idleStart: 29812,
_onTimeout: null,
_timerArgs: undefined,
_repeat: null,
_destroyed: true,
[Symbol(refed)]: null,
[Symbol(asyncId)]: 315,
[Symbol(triggerId)]: 4 },
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 0 },
_protocol:
Protocol {
_events: [Object],
_eventsCount: 7,
_maxListeners: undefined,
readable: true,
writable: true,
_config: [ConnectionConfig],
_connection: [Circular],
_callback: null,
_fatalError: [Circular],
_quitSequence: null,
_handshake: true,
_handshaked: false,
_ended: false,
_destroyed: false,
_queue: [Array],
_handshakeInitializationPacket: [HandshakeInitializationPacket],
_parser: [Parser] },
_connectCalled: true,
state: 'protocol_error',
threadId: 11 },
domainThrown: false }
So many "Access denied", This problem has troubled many people. I wonder if there is a unified way to solve this problem.
can you try 127.0.0.1 instead of 0.0.0.0?
Closing due to no response.