recently encountered problems, problems at work are as follows:

 Unhandled rejection SequelizeAccessDeniedError: Access denied for user'lupeng'@'localhost'(using password: YES) 

which is Node in the use of Sequlize to connect Mysql data times wrong, the key to see the colon error: access denied access is the key to illustrate the database connection error, there are problems, database connection access denied, or there is no corresponding operating authority, or is the wrong account password.

solves the problem on access right and account password error two points. Don't forget to find problems in other aspects. It's just a waste of time.

1. user privileges.

privilege problem starts from database. It confirms whether users are authorized to refresh the list of rights. That is, when using the Grant command to authorize the user, you should use the flush privileges command, which is a problem that many people will ignore.

attempts to restart the MySQL server if the user's authorization is no problem. Using the command /etc/init.d/mysql restart to restart the MySQL server, the reboot commands of different Linux versions may be different, and I am the Debain department.

, if the problem is not resolved, may not be a question of the user rights of the database.

2. account password problem,

account password error, this question sounds very much, but in the development process, many people will ignore it. Why do you say that? I use config-lite module to configure database parameters, because I will switch development in multiple system environments, and use config-lite module to load different parameter files through simple environment variable configuration. Specific usage reference: use for configuration files in different environments.

my problems appear here, open a terminal running project npm run test, package.json files are configured with test's running script NODE_ENV=test supervisor --harmony -i -i supervisor. The other open a terminal and command to run database synchronization, synchronization command is individually written in a JS script, the script reference data connection method (general),

 var connection method is as follows: Sequelize = require ('sequelize'); / / into the database configuration file var ('config-lite') (sqlConfig = require __dirname.Mysql; VAR sequelize) = new Sequelize (sqlConfig.database, sqlConfig.user, sqlConfig.password, dialect:,'mysql', sqlConfig.host {host:, pool: {max: 10, min: 0, idle: 10000}}); module.exports = sequelize; 

so when the databases are synchronized, always as the title error, however, feel right, only the final check found the problem: run the test script in the NODE_ENV environment variable is valid only in the current terminal, if you want to open A terminal to synchronize the database, you need to open the terminal in again set the environment variable. Otherwise, the database parameters that are loaded are inconsistent, that is to say, it is wrong to connect the username and password of the database.

all above is the summary of this article, I hope this paper has some reference value of learning to learn or work, if in doubt, you can exchange messages, thank you for the support of the script.


This concludes the body part