sql - 使用环境变量时访问被拒绝错误
问题描述
我是第一次使用 SQL。我正在使用 docker 容器来运行我的 SQL 在我的 node.js 应用程序中,我运行了 followig
let con = mysql.createConnection({
host: "localhost",
user: "user",
password: "password"
})
con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
})
它连接起来了。但是当我使用环境变量时我得到一个错误
let con = mysql.createConnection({
host: "localhost",
user: process.env.USERNAME,
password: process.env.PASSWORD
})
con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
})
我收到以下错误。
code: 'ER_ACCESS_DENIED_ERROR',
errno: 1045,
sqlMessage: "Access denied for user 'vidhyanand'@'172.17.0.1' (using password: YES)",
sqlState: '28000',
fatal: true
解决方案
推荐阅读
- c - 在 Vim 中打开 C 库头文件
- c++ - SFINAE 外部实现的 g++ 和 clang++ 不同的行为
- java - 为什么使用以下 android 代码看不到布局组件?
- android - 在android mediastore中保存文件时如何覆盖文件?
- kubernetes - k3s 的家庭助理配置
- javascript - 单击electronjs上的事件按钮
- jmeter - 无法在 jmeter 中添加 cookie
- purescript - Purescript 导入中缀类型构造函数
- python - Matplotlib 紧密布局设置矩形元组
- python - Korf 的魔方求解算法用 Python 实现?