thinkjs连接mysql_线上部署后,访问mysql出错

在使用thinkjs部署到线上环境并尝试连接mysql时遇到错误,日志显示'ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password: YES)'. 已确认配置文件中的用户名和密码正确,且3306端口未被占用。问题可能出在权限设置或数据库连接配置上。
摘要由CSDN通过智能技术生成

DESC

按照官方文档,pm2+nginx已部署成功,就是在连接mysql的时候出错。pm2 log输出日志如下:

0|MinecraftApp | Sat, 18 May 2019 06:56:42 GMT logic deprecated logic's __after method is deprecated, it will be discarded in the next version at node_modules/koa-compose/index.js:42:32

0|MinecraftApp | { Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password: YES)

0|MinecraftApp | at Handshake.Sequence._packetToError (/var/www/MinecraftApp/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)

0|MinecraftApp | at Handshake.ErrorPacket (/var/www/MinecraftApp/node_modules/mysql/lib/protocol/sequences/Handshake.js:123:18)

0|MinecraftApp | at Protocol._parsePacket (/var/www/MinecraftApp/node_modules/mysql/lib/protocol/Protocol.js:291:23)

0|MinecraftApp | at Parser._parsePacket (/var/www/MinecraftApp/node_modules/mysql/lib/protocol/Parser.js:433:10)

0|MinecraftApp | at Parser.write (/var/www/MinecraftApp/node_modules/mysql/lib/protocol/Parser.js:43:10)

0|MinecraftApp | at Protocol.write (/var/www/MinecraftApp/node_modules/mysql/lib/protocol/Protocol.js:38:16)

0|MinecraftApp | at Socket. (/var/www/MinecraftApp/node_modules/mysql/lib/Connection.js:91:28)

0|MinecraftApp | at Socket. (/var/www/MinecraftApp/node_modules/mysql/lib/Connection.js:525:10)

0|MinecraftApp | at emitOne (events.js:116:13)

0|MinecraftApp | at Socket.emit (events.js:211:7)

0|MinecraftApp | --------------------

0|MinecraftApp | at Protocol._enqueue (/var/www/MinecraftApp/node_modules/mysql/lib/protocol/Protocol.js:144:48)

0|MinecraftApp | at Protocol.handshake (/var/www/MinecraftApp/node_modules/mysql/lib/protocol/Protocol.js:51:23)

0|MinecraftApp | at PoolConnection.connect (/var/www/MinecraftApp/node_modules/mysql/lib/Connection.js:119:18)

0|MinecraftApp | at Pool.getConnection (/var/www/MinecraftApp/node_modules/mysql/lib/Pool.js:48:16)

0|MinecraftApp | at Promise (/var/www/MinecraftApp/node_modules/think-helper/index.js:83:10)

0|MinecraftApp | at new Promise ()

0|MinecraftApp | at args (/var/www/MinecraftApp/node_modules/think-helper/index.js:82:12)

0|MinecraftApp | at ThinkMysql.getConnection (/var/www/MinecraftApp/node_modules/think-mysql/index.js:73:73)

0|MinecraftApp | at debounceInstance.debounce (/var/www/MinecraftApp/node_modules/think-mysql/index.js:225:21)

0|MinecraftApp | at Promise.resolve.then (/var/www/MinecraftApp/node_modules/think-debounce/index.js:19:16)

0|MinecraftApp | code: 'ER_ACCESS_DENIED_ERROR',

0|MinecraftApp | errno: 1045,

0|MinecraftApp | sqlMessage: 'Access denied for user 'root'@'localhost' (using password: YES)',

0|MinecraftApp | sqlState: '28000',

0|MinecraftApp | fatal: true } { request:

0|MinecraftApp | { method: 'GET',

0|MinecraftApp | url: '/user/index',

0|MinecraftApp | header:

0|MinecraftApp | { 'x-real-ip': '180.171.171.254',

0|MinecraftApp | 'x-forwarded-for': '180.171.171.254',

0|MinecraftApp | host: 'www.lvci.cc',

0|MinecraftApp | 'x-nginx-proxy': 'true',

0|MinecraftApp | connection: 'upgrade',

0|MinecraftApp | 'cache-control': 'max-age=0',

0|MinecraftApp | 'upgrade-insecure-requests': '1',

0|MinecraftApp | 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36',

0|MinecraftApp | dnt: '1',

0|MinecraftApp | accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3',

0|MinecraftApp | 'accept-encoding': 'gzip, deflate, br',

0|MinecraftApp | 'accept-language': 'zh-CN,zh;q=0.9,zh-TW;q=0.8,en;q=0.7' } },

0|MinecraftApp | response:

0|MinecraftApp | { status: 200,

0|MinecraftApp | message: 'OK',

0|MinecraftApp | header: { 'x-powered-by': 'thinkjs-3.2.10' } },

0|MinecraftApp | app: { subdomainOffset: 2, proxy: true, env: 'production' },

0|MinecraftApp | originalUrl: '/user/index',

0|MinecraftApp | req: '',

0|MinecraftApp | res: '',

0|MinecraftApp | socket: '' }

其中,配置文件mysql的用户和密码确定没错,默认3306端口也没被占用。

ENV

OS Platform:

centOS 6

Node.js Version:

v8.16.0

ThinkJS Version:

code

// your code here

error message

// your error message here

more description

// your detail description

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值