1 回答
TA贡献1831条经验 获得超10个赞
以这种方式使用它。这应该有效:
var con = mysql.createConnection({
host: "localhost",
user: "apm",
password: "password123"
});
con.connect(function(err) {
if(err) throw err;
console.log('Connected!');
});
var sql = "CREATE DATABASE IF NOT EXISTS killEmAll";
con.query(sql, function (err, result) {
if (err) throw err;
console.log("Database created");
});
con.query('USE killEmAll', function (err, result) {
if (err) throw err;
console.log("killEmAll is using");
})
sql = "CREATE TABLE IF NOT EXISTS users (firstName VARCHAR(255), secondName VARCHAR(255), email VARCHAR(255), username VARCHAR(255), password VARCHAR(255))";
con.query(sql, function (err, result) {
if (err) throw err;
console.log("Database created");
});
添加回答
举报