文章详情页
node.js - node连接mysql失败
浏览:141日期:2024-08-04 08:47:07
问题描述
利用node连接mysql一直连接不上,user和password没有错误
问题解答
回答1:官方例子,照此方法把 err 整出来看看,除了 stack 还可以看看其它内容,比如 message 啊之类的,然后再来定位错误哇。
var mysql = require(’mysql’);var connection = mysql.createConnection({ host : ’example.org’, user : ’bob’, password : ’secret’}); connection.connect(function(err) { if (err) { console.error(’error connecting: ’ + err.stack); return; } console.log(’connected as id ’ + connection.threadId);});回答2:
端口号也写上试试
相关文章:
1. docker容器呢SSH为什么连不通呢?2. 关docker hub上有些镜像的tag被标记““This image has vulnerabilities””3. nignx - docker内nginx 80端口被占用4. debian - docker依赖的aufs-tools源码哪里可以找到啊?5. 前端 - ng-view不能加载进模板6. android clickablespan获取选中内容7. docker网络端口映射,没有方便点的操作方法么?8. python - from ..xxxx import xxxx到底是什么意思呢?9. javascript - iframe 为什么加载网页的时候滚动条这样显示?10. 请教各位大佬,浏览器点 提交实例为什么没有反应
排行榜
