Tag Archives: NodeJs

NodeJS Connect MYSQL Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client

I’m mysql8 For versions above 0, start to report errors when connecting to the MySQL database in the server with nodejs

This means that the server starts up, but there is an error in the password protocol in the database. The result I found on the Internet tells me that it is mysql8.0 supports a new cryptographic protocol, but nodejs does not support it at present.

The following is my solution after avoiding the pit, which may not be applicable to everyone

1. Log in to MySQL server

Open the command line as an administrator and enter

mysql -u administrator -p

If you are prompted that MySQL is not an executable file, you can CD on the command line to the bin directory in mysql, or add Mysql to the environment variable

Note: the above root is the user name you want to modify. It may not be administrator. Mine is administrator

2. Enter the password

Then enter the password and enter mysql

3. Select database

Therefore, first we need to select the database and enter it on the command line

use mysql

Note: This is mysql, not any other name, unless you modify the name of the table in the database where the user name and password are stored, but the probability is very small, and you can’t move there.

If the wrong database is selected, the following errors will be prompted in the subsequent password blank operation

4. Leave password blank

If the original password is not blank and the password is modified directly, an error will be reported

Password blank operation, enter

update user set authentication_string='' where user='administrator';

The above administrator is still the user name you need to modify the password protocol

5. Refresh

This step is important

flush privileges;

6. Modify password and agreement

I’ve been stuck in this step for a long time

When I modify the password agreement, the error in the figure appears

After checking a lot of information, I understand

Open the database, MySQL database and user table, and you can see

The host before the user name I want to modify is’% ‘instead of’ localhost ‘, so I need to change the localhost in the command to%

alter user 'administrator'@'%' identified with mysql_native_password by '123456';

The above administrator is the user name you need to change your password, and 123456 is your password

This completes all steps

MySQL forgot password modification, etc. many online tutorials don’t seem to apply to MySQL 8 0. Write this part when you have time.

After installing nodejs, running NPM – V will cause (module. JS: 339 throw err..) error. Solution

Introduction: Recently, after installing nodejs, I ran node -v on windows cmd without any problems, and was dumbfounded when I typed npm -v and came up with the following series of errors shown below:

Error: Cannot find module ‘npmlog’ at Function.Module._resolveFilename

(module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at /usr/local/lib/node_modules/npm/bin/npm-cli.js:18:11
at Object. (/usr/local/lib/node_modules/npm/bin/npm-cli.js:75:3)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)

When installing plugins such as express, the system will install to the default path (unless you have set the path) under windows is C:\Users\jerry\AppData\Roaming

Solution:

windows

rmdir %appdata%\npm\node_modules /s /q

Unix or Linux

rm -rf /usr/local/bin/node_modules

Nodejs throws an error when listening to the port under Linux

june@june-Satellite-C600:~/nodejs/lesson$noderandom.js
RandomNumberGeneratorRunning…

events.js:72
thrower;//Unhandled'error'event
^
Error:listenEACCES
aterrnoException(net.js:904:11)
atServer._listen2(net.js:1023:19)
atlisten(net.js:1064:10)
atServer.listen(net.js:1138:5)
atObject.<anonymous>(/home/june/nodejs/lesson/random.js:50:8)
atModule._compile(module.js:456:26)
atObject.Module._extensions..js(module.js:474:10)
atModule.load(module.js:356:32)
atFunction.Module._load(module.js:312:12)
atFunction.Module.runMain(module.js:497:10)

There are two ways to solve the problem

1:sudo node *.js —–> Root authority solution

2: Set the port number above 1024 in the code; Because Linux monitors & lt; 1024 port needs root permission, > No need