我尝试使用ID 273 更改用户的密码,但我尝试了所有内容但无效。我打算用它来管理我的数据库node.js
这是我的代码:
var mysql = require('mysql');
var connection = mysql.createConnection({
host: '127.0.0.1',
user: 'root',
password: 'root',
database: 'kitsune',
//connectionLimit: 50,
port: 3306 });
connection.connect(function(err) {
if (err) throw err;
});
const iduser = 273; // ID
const newPassword = "dfgfgSD22";
// Change password to uppercased md5
var insertQuery = "UPDATE `penguins` SET `Password` = UPPER(MD5('" + newPassword + "') WHERE ID = " + iduser + ";"
connection.query(insertQuery, function(error, results, fields) {;
console.log(insertQuery);
console.log(JSON.stringify(results));
if (error) throw error;
});
module.exports = connection;
connection.end(); // End connection
它应该以md5大写的id 273 的用户更新密码,但我不断收到以下错误:
错误:ER_PARSE_ERROR:您的SQL语法中有错误;检查 与您的MariaDB服务器版本对应的手册 在第1行'WHERE
ID
= 273'附近使用的语法
打印出的查询:
UPDATE
penguins
SETPassword
= UPPER(MD5('dfgfgSD22')WHERE ID = 273;
答案 0 :(得分:0)
你写过
var insertQuery = "UPDATE `penguins` SET `Password` = UPPER(MD5('" + newPassword + "') WHERE ID = " + iduser + ";"
这里
`Password` = UPPER(MD5('" + newPassword + "')
现在只有一个括号正在关闭
`Password` = UPPER(MD5('" + newPassword + "'))
替换以下行
var insertQuery = "UPDATE `penguins` SET `Password` = UPPER(MD5('" + newPassword + "')) WHERE ID = " + iduser + ";"