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

The whole process of realizing website internationalization using Vite2 and Vue3

Table of contents Preface Install vue-i18n Config...

Vue implements graphic verification code login

This article example shares the specific code of ...

React hooks pros and cons

Table of contents Preface advantage: shortcoming:...

Beginners understand MySQL deadlock problem from source code

After many difficult single-step debugging late a...

Introduction to Jenkins and how to deploy Jenkins with Docker

1. Related concepts 1.1 Jenkins Concepts: Jenkins...

Detailed explanation of application scenarios of filters in Vue

filter is generally used to filter certain values...

jQuery implements a simple comment area

This article shares the specific code of jQuery t...

Mysql transaction isolation level principle example analysis

introduction You must have encountered this in an...

NodeJs high memory usage troubleshooting actual combat record

Preface This is an investigation caused by the ex...

A friendly alternative to find in Linux (fd command)

The fd command provides a simple and straightforw...

Summary of some common uses of refs in React

Table of contents What are Refs 1. String type Re...

Why is it slow when using limit and offset paging scenarios?

Let’s start with a question Five years ago when I...

Detailed explanation of Cgroup, the core principle of Docker

The powerful tool cgroup in the kernel can not on...