0

我遇到了 Sequelize for Express (node.js) 的问题。我尝试将 MAMP Mac 中的 MySQL 数据库与 Sequelize for express 连接,但它不起作用,我不明白为什么,但出现错误:

也许我必须编辑 MySQL 配置文件以注释“MAMP_skip-networking_MAMP”,但我没有找到 MAC 的 MySQL Conf 文件...

我的代码:

var Sequelize = require("sequelize");

var db = new Sequelize('express', 'root', 'root', {
    host: '127.0.0.1',
    port: '3306'
});

var Project = db.define('Project', {
    date: Sequelize.DATE,
    title: Sequelize.STRING,
    description: Sequelize.TEXT
});

var project = Project.build({
    date: new Date(),
    title: 'Mon premiéé projeétçç!!',
    description: 'dsqlmdskq lkqskl ksqlmk lsmdqklm'
});

project
    .save();
4

2 回答 2

5

Try using port 8889 instead of 3306.

于 2013-02-13T09:15:14.737 回答
0

尝试这个:

var Sequelize = require("sequelize"); 
var db = new Sequelize('express', 'root', 'root', {
  host: '127.0.0.1',
  port: '3306' 
});

var Project = db.define('Project', {
  date: Sequelize.DATE,
  title: Sequelize.STRING,
  description: Sequelize.TEXT 
});

db.sync().success(function() {
  var project = Project.build({
    date: new Date(),
    title: 'Mon premiéé projeétçç!!',
    description: 'dsqlmdskq lkqskl ksqlmk lsmdqklm' 
  });

  project.save();
})
于 2013-02-13T08:47:59.070 回答