【发布时间】:2022-01-12 06:08:33
【问题描述】:
我正在使用 mysql 数据库在“MacOS Mojave 10.14.6”中构建一个 Expo 应用程序。我想创建忘记密码页面,该页面需要向用户发送电子邮件通知以重置密码。所以我正在编写一个 Node.js 程序将连接到 Mysql。但我收到错误。
下面是 Node.js 数据库程序:
数据库.js:
var mysql=require('mysql2');
var connection=mysql.createConnection({
host:'localhost',
user:'root',
password:'',
database:'*******'
});
connection.connect((err) => {
if(!err)
console.log('Database is connected!');
else
console.log('Database not connected! : '+ JSON.stringify(err, undefined,2));
});
module.exports = connection;
运行上述程序后,我收到以下错误:
Database not connected! : {
"code": "ER_ACCESS_DENIED_ERROR",
"errno": 1045,
"sqlState": "28000",
"sqlMessage": "Access denied for user 'root'@'localhost' (using password: NO)"
}
我尝试使用以下命令更改 Mysql Workbench 中的密码:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Test123'; 但它给出了一个错误:
ALTER 和 SYSTEM USER 用法不正确。
我可以使用用户名和密码从 Mysql Workbench 连接到数据库。谁能告诉我哪里出错了。在此先感谢。
【问题讨论】:
-
你检查过this吗?
标签: mysql node.js macos expo mysql-workbench