我在mysql数据库中使用node.js。
我是这样使用配置的:
var mysql = require('mysql');
var client = mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'java1234',
port: '3306',
database: 'sample'
});
然后我得到这些错误信息:
错误:er\u access\u denied\u错误:handshake.sequence处拒绝用户'root'@'localhost'(使用密码:no)的访问。\u packettoerror(c:\node\test11\u users\node\u modules\mysql\lib\protocol\sequences\sequence.js:47:14)at handshake.errorpacket(c:\node\test11\u users\node\u modules\mysql\lib\protocol\sequences\handshake.js:124:18)at protocol.\u parsepacket(c:\node\test11\u users\node\u modules\mysql\lib\protocol\protocol.js:278:23)在parser.write(c:\node\test11\u users\node\u modules\mysql\lib\protocol\parser.js:76:12)在protocol.write(c:\node\test11\u users\node\u modules\mysql\lib\protocol\protocol.js:38:16)在socket(c:\node\test11\u users\node\u modules\mysql\lib\connection.js:91:28)位于套接字(c:\node\test11\u users\node\u modules\mysql\lib\connection.js:502:10)at emitone(events.js:116:13)at socket.emit(events.js:211:7)at addchunk(\u stream\u readable.js:263:12)
2条答案
按热度按时间bogh5gae1#
从连接选项中删除端口,然后重试
jv4diomz2#
-at protocol.\u在protocol.handshake排队(c:\node\test11\u users\node\u modules\mysql\lib\protocol\protocol.js:144:48)(c:\node\test11\u users\node\u modules\mysql\lib\protocol\protocol.js:51:23)在connection.connect(c:\node\test11\u users\node\u modules\mysql\lib\connection.js:118:18)在connection.query(c:\node\test11\u users\node\u modules\mysql\lib\connection.js:453:10)在connection.query(c:\node\test11\u users\node\u modules\mysql\lib\connection.js:198:8)在c:\node\test11\u users\routes\users.js:26:10 at layer.handle[作为handle\u请求](c:\node\test11\u users\node\u modules\express\lib\router\layer.js:95:5)at next(c:\node\test11\u users\node\u modules\express\lib\router\route.js:137:13)at route.dispatch(c:\node\test11\u users\node\u modules\express\lib\router\route.js:112:3)at layer.handle[作为处理\u请求](c:\node\test11 \u users\node \u modules\express\lib\router\layer.js:95:5)
但我解决不了这个问题。谢谢你的解释。