Problems and solutions encountered when connecting node to mysql database

Problems and solutions encountered when connecting node to mysql database

I installed a new version of MySQL (8.0.21) today, and an error occurred when connecting to the database using the node framework:

Client does not support authentication protocol requested by server; consider upgrading MySQL client

The reason is that MySQL 8.0 has changed the encryption plug-in, but the database management client still uses the encryption method of the old version. This is mainly due to the configuration process of the Authentication Method during the installation of MySQL 8.0. There are different encryption methods, so if you choose strong encryption (which should be the default), the above error problem will occur. In this case, just change the encryption method to keep the encryption method of the old version and it will be ok.

1. Windows users use the terminal to enter the database and enter:

alter user 'root'@'%' identified with mysql_native_password by '密码' // Reset password flush privileges // Refresh privilege configuration

It can be solved!

2. Mac users, please see here

I also used the default strong encryption method during the installation process. The solution is also very simple. First, open系統偏好設置

insert image description here

Click MySQL to enter the database

insert image description here

After entering, I found an interface like this. You can see that the database uses strong encryption.

insert image description here

Then we select Legacy Password below and set a password

insert image description here

Click OK and finally restart the database!

Because I changed to Mac, I can't personally follow the steps on Windows. Please forgive me if there are any incomplete details. You can also search for other tutorials on your own!

Summarize

This is the end of this article about the problems and solutions encountered when connecting node to mysql database. For more relevant content about connecting node to mysql database, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Solution to the garbled problem of inserting mysql database with nodejs and C language
  • Simple encapsulation example of nodejs connecting to mysql database - mysql module
  • MySQL database configuration and connection under node.js platform
  • Detailed explanation of node operation mysql database instance
  • Node.js database operation: querying MySQL database (Part 2)
  • Node.js operates mysql database to add, delete, modify and query

<<:  Nginx domain forwarding usage scenario code example

>>:  What does the legendary VUE syntax sugar do?

Recommend

A simple and in-depth study of async and await in JavaScript

Table of contents 1. Introduction 2. Detailed exp...

Detailed explanation of Strict mode in JavaScript

Table of contents Introduction Using Strict mode ...

uni-app WeChat applet authorization login implementation steps

Table of contents 1. Application and configuratio...

How to modify create-react-app's configuration without using eject

1. Why is eject not recommended? 1. What changes ...

Basic installation process of mysql5.7.19 under winx64 (details)

1. Download https://dev.mysql.com/downloads/mysql...

How to import js configuration file on Vue server

Table of contents background accomplish Supplemen...

Two methods to disable form controls in HTML: readonly and disabled

In the process of making web pages, we often use f...

Weird and interesting Docker commands you may not know

Intro Introduces and collects some simple and pra...

Docker image import and export code examples

Import and export of Docker images This article i...

Detailed explanation of Linux DMA interface knowledge points

1. Two types of DMA mapping 1.1. Consistent DMA m...

How to set directory whitelist and IP whitelist in nginx

1. Set a directory whitelist: Do not set restrict...

How to implement a password strength detector in react

Table of contents Preface use Component Writing D...

js and jquery to achieve tab status bar switching effect

Today we will make a simple case, using js and jq...