使用Sequlize连接mysql出现3306

149 阅读1分钟
const Sequelize = require('sequelize')
// const config = require('./config')

const conf = {
  host: 'localhost',
  dialect: 'mysql',
  dialectOptions: {
    socketPath: '/tmp/mysql.sock' // 指定套接字文件路径 指明当前配置
  } 
}
const seq = new Sequelize('koa2_weibo_db', 'root', '123456', conf)
// 测试连接

seq.authenticate().then(res => {
  console.log('ok')
}).catch((err) => {
  console.log(err)
})

module.exports = seq