老师好
db.js代码如下。
这样写会报错:Client does not support authentication protocol requested by server;
consider upgrading MySQL client
可是把module.exports改成 module.exports=MYSQL_CONFIG就不会报错。这是为什么啊
const env=process.env.NODE_ENV
let MYSQL_CONFIG
let REDIS_CONFIG
if(env==="dev"){
MYSQL_CONFIG={
host:"localhost",
user:"root",
password:"lwjkkkbbb1997",
port:"3306",
database:"myblog"
}
REDIS_CONFIG={
port:"6379",
host:"127.0.0.1"
}
}
if(env==="production"){
MYSQL_CONFIG={
host:"localhost",
user:"root",
password:"lwjkkkbbb1997",
port:"3306",
database:"myblog"
}
REDIS_CONFIG={
port:"6379",
host:"127.0.0.1"
}
}
module.exports={
MYSQL_CONFIG,
REDIS_CONFIG
}