I'm getting this error when I try to use dotenv
ERROR: Host 'DESKTOP-I4V1RGG' is not allowed to connect to this MySQL server
for some reason, the HOSTNAME is being read as the name of my computer and not as 'localhost' as I defined in the .env
This is my config.js:
require('dotenv').config();
module.exports = {
development: {
username: process.env.MYSQL_USER,
password: process.env.MYSQL_PASSWORD,
database: 'database_name',
host: process.env.HOSTNAME,
dialect: 'mysql',
},
};
and this is my .env:
JWT_SECRET=hardcoded_secret
MYSQL_USER=root
MYSQL_PASSWORD=1234
HOSTNAME=localhost
I think this may have something to do with Windows environment variables. Any guess?
ps: I'm a newbie. Please be kind.
---- edit: I changed the variable name from HOSTNAME to MYCOMPUTER, and it works perfectly. The problem is the word HOSTNAME that instead of looking for what I set in the .env, it looks in some Windows configuration. This happens quite often since I switched to Windows OS.