0

I am trying to run this code:

from flask_sqlalchemy import SQLAlchemy

import mysql.connector
import csv
import pandas as pd

mydb = mysql.connector.connect(
  host="127.0.0.1",
  user="root",
  passwd="abc123",
  database="db"

)

But I am receiving this error:

    Traceback (most recent call last):
      File "C:\Users\user123\Desktop\SQLtest\setup.py", line 10, in <module>
        passwd="abc123",

    .
    .
    .
 "Authentication plugin '{0}' is not supported".format(plugin_name))
mysql.connector.errors.NotSupportedError: Authentication plugin 'caching_sha2_password' is not supported

Any help would be appreciated.

1 Answer 1

1

This error appears because MySQL 8 uses caching_sha2_password as the default authentication plugin rather than mysql_native_password.

To solve this issue, try adding auth_plugin='mysql_native_password' to your connection parameters - to make your connection uses the native authentication plugin - as below:

mydb = mysql.connector.connect(
  host="127.0.0.1",
  user="root",
  passwd="abc123",
  database="db",
  auth_plugin="mysql_native_password"
)
Sign up to request clarification or add additional context in comments.

3 Comments

I tried that, but still getting this error: "Authentication plugin '{0}' is not supported".format(plugin_name)) mysql.connector.errors.NotSupportedError: Authentication plugin 'caching_sha2_password' is not supported
Can you try using mysql-connector-python instead of mysql-connector? install it via pip, e.g: pip install mysql-connector-python
I created a new database and connected to it and now it works? Thanks for your help anyway

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.